d49c3e167f
* New SessionState to consolidate email, access token and refresh token * split ServeHttp into individual methods * log on session renewal * log on access token refresh * refactor cookie encription/decription and session state serialization
30 lines
756 B
Go
30 lines
756 B
Go
package providers
|
|
|
|
import (
|
|
"github.com/bitly/oauth2_proxy/cookie"
|
|
)
|
|
|
|
type Provider interface {
|
|
Data() *ProviderData
|
|
GetEmailAddress(*SessionState) (string, error)
|
|
Redeem(string, string) (*SessionState, error)
|
|
ValidateSessionState(*SessionState) bool
|
|
GetLoginURL(redirectURI, finalRedirect string) string
|
|
RefreshSessionIfNeeded(*SessionState) (bool, error)
|
|
SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
|
|
CookieForSession(*SessionState, *cookie.Cipher) (string, error)
|
|
}
|
|
|
|
func New(provider string, p *ProviderData) Provider {
|
|
switch provider {
|
|
case "myusa":
|
|
return NewMyUsaProvider(p)
|
|
case "linkedin":
|
|
return NewLinkedInProvider(p)
|
|
case "github":
|
|
return NewGitHubProvider(p)
|
|
default:
|
|
return NewGoogleProvider(p)
|
|
}
|
|
}
|