forked from bitly/oauth2_proxy
-
Notifications
You must be signed in to change notification settings - Fork 6
/
providers.go
39 lines (36 loc) · 1.11 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
package providers
import (
"github.com/bitly/oauth2_proxy/cookie"
)
type Provider interface {
Data() *ProviderData
GetUserDetails(*SessionState) (map[string]string, error)
GetUserName(*SessionState) (string, error)
GetGroups(*SessionState, string) (map[string]string, error)
Redeem(string, string) (*SessionState, error)
ValidateGroup(*SessionState) bool
ValidateExemptions(*SessionState) (bool, string)
ValidateSessionState(*SessionState) bool
GetLoginURL(redirectURI, finalRedirect string) string
RefreshSessionIfNeeded(*SessionState) (bool, error)
SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
CookieForSession(*SessionState, *cookie.Cipher) (string, error)
}
func New(provider string, p *ProviderData) (Provider, error) {
switch provider {
case "linkedin":
return NewLinkedInProvider(p), nil
case "facebook":
return NewFacebookProvider(p), nil
case "github":
return NewGitHubProvider(p), nil
case "azure":
return NewAzureProvider(p), nil
case "gitlab":
return NewGitLabProvider(p), nil
case "oidc":
return NewOIDCProvider(p), nil
default:
return NewGoogleProvider(p), nil
}
}