cb48577ede
See the README for usage with Dex or any other OIDC provider. To test run a backend: python3 -m http.server Run dex and modify the example config with the proxy callback: go get github.com/coreos/dex/cmd/dex cd $GOPATH/src/github.com/coreos/dex sed -i.bak \ 's|http://127.0.0.1:5555/callback|http://127.0.0.1:5555/oauth2/callback|g' \ examples/config-dev.yaml make ./bin/dex serve examples/config-dev.yaml Then run the oauth2_proxy oauth2_proxy \ --oidc-issuer-url http://127.0.0.1:5556/dex \ --upstream http://localhost:8000 \ --client-id example-app \ --client-secret ZXhhbXBsZS1hcHAtc2VjcmV0 \ --cookie-secret foo \ --email-domain '*' \ --http-address http://127.0.0.1:5555 \ --redirect-url http://127.0.0.1:5555/oauth2/callback \ --cookie-secure=false Login with the username/password "admin@example.com:password"
39 lines
966 B
Go
39 lines
966 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)
|
|
ValidateGroup(string) bool
|
|
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 "facebook":
|
|
return NewFacebookProvider(p)
|
|
case "github":
|
|
return NewGitHubProvider(p)
|
|
case "azure":
|
|
return NewAzureProvider(p)
|
|
case "gitlab":
|
|
return NewGitLabProvider(p)
|
|
case "oidc":
|
|
return NewOIDCProvider(p)
|
|
default:
|
|
return NewGoogleProvider(p)
|
|
}
|
|
}
|