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