mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-11-28 09:08:44 +02:00
38 lines
967 B
Go
38 lines
967 B
Go
package providers
|
|
|
|
import (
|
|
"github.com/pusher/oauth2_proxy/cookie"
|
|
)
|
|
|
|
type Provider interface {
|
|
Data() *ProviderData
|
|
GetEmailAddress(*SessionState) (string, error)
|
|
GetUserName(*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)
|
|
}
|
|
|
|
func New(provider string, p *ProviderData) Provider {
|
|
switch provider {
|
|
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)
|
|
case "oidc":
|
|
return NewOIDCProvider(p)
|
|
default:
|
|
return NewGoogleProvider(p)
|
|
}
|
|
}
|