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