2015-03-30 15:30:27 -04:00
|
|
|
package providers
|
|
|
|
|
2015-06-23 07:23:39 -04:00
|
|
|
import (
|
|
|
|
"github.com/bitly/oauth2_proxy/cookie"
|
|
|
|
)
|
|
|
|
|
2015-03-30 15:30:27 -04:00
|
|
|
type Provider interface {
|
|
|
|
Data() *ProviderData
|
2015-06-23 07:23:39 -04:00
|
|
|
GetEmailAddress(*SessionState) (string, error)
|
|
|
|
Redeem(string, string) (*SessionState, error)
|
2015-08-20 03:07:02 -07:00
|
|
|
ValidateGroup(string) bool
|
2015-06-23 07:23:39 -04:00
|
|
|
ValidateSessionState(*SessionState) bool
|
2015-06-06 14:15:43 -04:00
|
|
|
GetLoginURL(redirectURI, finalRedirect string) string
|
2015-06-23 07:23:39 -04:00
|
|
|
RefreshSessionIfNeeded(*SessionState) (bool, error)
|
|
|
|
SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
|
|
|
|
CookieForSession(*SessionState, *cookie.Cipher) (string, error)
|
2015-03-30 15:30:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func New(provider string, p *ProviderData) Provider {
|
|
|
|
switch provider {
|
2015-03-31 15:17:17 -04:00
|
|
|
case "myusa":
|
|
|
|
return NewMyUsaProvider(p)
|
2015-04-17 15:33:17 -07:00
|
|
|
case "linkedin":
|
|
|
|
return NewLinkedInProvider(p)
|
2016-06-23 08:29:44 -04:00
|
|
|
case "facebook":
|
|
|
|
return NewFacebookProvider(p)
|
2015-05-20 23:23:48 -04:00
|
|
|
case "github":
|
|
|
|
return NewGitHubProvider(p)
|
2015-11-09 09:28:34 +01:00
|
|
|
case "azure":
|
|
|
|
return NewAzureProvider(p)
|
2016-02-17 06:19:52 -06:00
|
|
|
case "gitlab":
|
|
|
|
return NewGitLabProvider(p)
|
2015-03-30 15:30:27 -04:00
|
|
|
default:
|
|
|
|
return NewGoogleProvider(p)
|
|
|
|
}
|
|
|
|
}
|