mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-12-12 11:15:02 +02:00
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package providers
|
|
|
|
import (
|
|
"github.com/pusher/oauth2_proxy/pkg/apis/sessions"
|
|
"github.com/pusher/oauth2_proxy/pkg/encryption"
|
|
)
|
|
|
|
// Provider represents an upstream identity provider implementation
|
|
type Provider interface {
|
|
Data() *ProviderData
|
|
GetEmailAddress(*sessions.SessionState) (string, error)
|
|
GetUserName(*sessions.SessionState) (string, error)
|
|
Redeem(string, string) (*sessions.SessionState, error)
|
|
ValidateGroup(string) bool
|
|
ValidateSessionState(*sessions.SessionState) bool
|
|
GetLoginURL(redirectURI, finalRedirect string) string
|
|
RefreshSessionIfNeeded(*sessions.SessionState) (bool, error)
|
|
SessionFromCookie(string, *encryption.Cipher) (*sessions.SessionState, error)
|
|
CookieForSession(*sessions.SessionState, *encryption.Cipher) (string, error)
|
|
}
|
|
|
|
// New provides a new Provider based on the configured provider string
|
|
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 "keycloak":
|
|
return NewKeycloakProvider(p)
|
|
case "azure":
|
|
return NewAzureProvider(p)
|
|
case "gitlab":
|
|
return NewGitLabProvider(p)
|
|
case "oidc":
|
|
return NewOIDCProvider(p)
|
|
case "login.gov":
|
|
return NewLoginGovProvider(p)
|
|
case "bitbucket":
|
|
return NewBitbucketProvider(p)
|
|
default:
|
|
return NewGoogleProvider(p)
|
|
}
|
|
}
|