-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproviders.go
47 lines (43 loc) · 1.28 KB
/
providers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package providers
import (
"github.com/bitly/oauth2_proxy/cookie"
)
// Provider is the primary interface for an authentication provider
// all provider
type Provider interface {
Data() *ProviderData
GetEmailAddress(*SessionState) (string, error)
Redeem(string, string) (*SessionState, error)
ValidateGroup(string) bool
ValidateSessionState(*SessionState) bool
GetLoginURL(redirectURI, finalRedirect string) string
RefreshSessionIfNeeded(*SessionState) (bool, error)
SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
CookieForSession(*SessionState, *cookie.Cipher) (string, error)
}
// RoleProvider is an optional interface that exposes a list of roles
// for a user. For Providers like GitHub this would be the teams the user
// is a member of.
type RoleProvider interface {
GetUserRoles() string
SetUserRoles(string) (bool, error)
}
// New gives you an instance of the given provider
func New(provider string, p *ProviderData) Provider {
switch provider {
case "myusa":
return NewMyUsaProvider(p)
case "linkedin":
return NewLinkedInProvider(p)
case "facebook":
return NewFacebookProvider(p)
case "github":
return NewGitHubProvider(p)
case "azure":
return NewAzureProvider(p)
case "gitlab":
return NewGitLabProvider(p)
default:
return NewGoogleProvider(p)
}
}