2015-03-30 21:30:27 +02:00
|
|
|
package providers
|
|
|
|
|
2015-06-23 13:23:39 +02:00
|
|
|
import (
|
2020-05-05 17:53:33 +02:00
|
|
|
"context"
|
|
|
|
|
2020-09-29 18:44:42 +02:00
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/sessions"
|
2015-06-23 13:23:39 +02:00
|
|
|
)
|
|
|
|
|
2018-12-20 12:37:59 +02:00
|
|
|
// Provider represents an upstream identity provider implementation
|
2015-03-30 21:30:27 +02:00
|
|
|
type Provider interface {
|
|
|
|
Data() *ProviderData
|
2021-03-07 01:33:13 +02:00
|
|
|
GetLoginURL(redirectURI, finalRedirect string, nonce string) string
|
|
|
|
Redeem(ctx context.Context, redirectURI, code string) (*sessions.SessionState, error)
|
2021-02-17 22:15:45 +02:00
|
|
|
// Deprecated: Migrate to EnrichSession
|
2020-05-05 17:53:33 +02:00
|
|
|
GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error)
|
2020-10-24 07:06:50 +02:00
|
|
|
EnrichSession(ctx context.Context, s *sessions.SessionState) error
|
2020-09-27 02:29:34 +02:00
|
|
|
Authorize(ctx context.Context, s *sessions.SessionState) (bool, error)
|
2020-10-24 07:06:50 +02:00
|
|
|
ValidateSession(ctx context.Context, s *sessions.SessionState) bool
|
2021-03-07 01:33:13 +02:00
|
|
|
RefreshSession(ctx context.Context, s *sessions.SessionState) (bool, error)
|
2020-11-16 04:57:48 +02:00
|
|
|
CreateSessionFromToken(ctx context.Context, token string) (*sessions.SessionState, error)
|
2015-03-30 21:30:27 +02:00
|
|
|
}
|
|
|
|
|
2018-12-20 12:37:59 +02:00
|
|
|
// New provides a new Provider based on the configured provider string
|
2015-03-30 21:30:27 +02:00
|
|
|
func New(provider string, p *ProviderData) Provider {
|
|
|
|
switch provider {
|
2015-04-18 00:33:17 +02:00
|
|
|
case "linkedin":
|
|
|
|
return NewLinkedInProvider(p)
|
2016-06-23 14:29:44 +02:00
|
|
|
case "facebook":
|
|
|
|
return NewFacebookProvider(p)
|
2015-05-21 05:23:48 +02:00
|
|
|
case "github":
|
|
|
|
return NewGitHubProvider(p)
|
2019-07-28 15:54:39 +02:00
|
|
|
case "keycloak":
|
|
|
|
return NewKeycloakProvider(p)
|
2021-03-14 19:20:59 +02:00
|
|
|
case "keycloak-oidc":
|
|
|
|
return NewKeycloakOIDCProvider(p)
|
2015-11-09 10:28:34 +02:00
|
|
|
case "azure":
|
|
|
|
return NewAzureProvider(p)
|
2021-06-13 10:00:12 +02:00
|
|
|
case "adfs":
|
|
|
|
return NewADFSProvider(p)
|
2016-02-17 14:19:52 +02:00
|
|
|
case "gitlab":
|
|
|
|
return NewGitLabProvider(p)
|
2017-05-09 20:20:35 +02:00
|
|
|
case "oidc":
|
|
|
|
return NewOIDCProvider(p)
|
2019-03-20 15:44:51 +02:00
|
|
|
case "login.gov":
|
|
|
|
return NewLoginGovProvider(p)
|
2019-08-16 15:53:22 +02:00
|
|
|
case "bitbucket":
|
|
|
|
return NewBitbucketProvider(p)
|
2019-06-05 18:59:04 +02:00
|
|
|
case "nextcloud":
|
|
|
|
return NewNextcloudProvider(p)
|
2020-01-15 13:09:34 +02:00
|
|
|
case "digitalocean":
|
|
|
|
return NewDigitalOceanProvider(p)
|
2020-11-11 07:53:56 +02:00
|
|
|
case "google":
|
2015-03-30 21:30:27 +02:00
|
|
|
return NewGoogleProvider(p)
|
2020-11-11 07:53:56 +02:00
|
|
|
default:
|
|
|
|
return nil
|
2015-03-30 21:30:27 +02:00
|
|
|
}
|
|
|
|
}
|