oauth2_proxy/providers/providers.go

40 lines
1.1 KiB
Go
Raw Permalink Normal View History

package providers
import (
2018-11-27 11:45:05 +00:00
"github.com/pusher/oauth2_proxy/cookie"
)
// Provider represents an upstream identity provider implementation
type Provider interface {
Data() *ProviderData
GetEmailAddress(*SessionState) (string, error)
GetUserName(*SessionState) (string, error)
Redeem(string, string) (*SessionState, error)
ValidateGroup(string) bool
ValidateSessionState(*SessionState) bool
2015-06-06 18:15:43 +00:00
GetLoginURL(redirectURI, finalRedirect string) string
RefreshSessionIfNeeded(*SessionState) (bool, error)
SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
CookieForSession(*SessionState, *cookie.Cipher) (string, error)
}
// New provides a new Provider based on the configured provider string
func New(provider string, p *ProviderData) Provider {
switch provider {
2015-04-17 22:33:17 +00:00
case "linkedin":
return NewLinkedInProvider(p)
case "facebook":
return NewFacebookProvider(p)
2015-05-21 03:23:48 +00:00
case "github":
return NewGitHubProvider(p)
2015-11-09 08:28:34 +00:00
case "azure":
return NewAzureProvider(p)
2016-02-17 12:19:52 +00:00
case "gitlab":
return NewGitLabProvider(p)
case "oidc":
return NewOIDCProvider(p)
default:
return NewGoogleProvider(p)
}
}