Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingClientID = errors.New("no client id provided") ErrMissingClientSecret = errors.New("no client secret provided") )
var ErrInvalidSetup error = errors.New("providers.oauth.auth-url, providers.oauth.token-url, providers.oauth.user-url, providers.oauth.token-style must be set")
var ErrMissingIssuerUrl = errors.New("no issuer url provided")
Functions ¶
func GetUserFromBytes ¶
GetUser extracts a UserID located at the (dot notation) path (UserPath) in the json io.Reader of the UserURL
Types ¶
type OAuth ¶
type OAuth struct {
AuthURL string `long:"auth-url" env:"AUTH_URL" description:"Auth/Login URL"`
TokenURL string `long:"token-url" env:"TOKEN_URL" description:"Token URL"`
UserURL string `long:"user-url" env:"USER_URL" description:"URL used to retrieve user info"`
ClientID string `long:"client-id" env:"CLIENT_ID" description:"Client ID"`
ClientIDFile string `long:"client-id-file" env:"CLIENT_ID_FILE" description:"Path to a file containing the client id"`
ClientSecret string `long:"client-secret" env:"CLIENT_SECRET" description:"Client Secret" json:"-"`
ClientSecretFile string `long:"client-secret-file" env:"CLIENT_SECRET_FILE" description:"Path to a file containing the client secret"`
TokenStyle types.TokenStyle `` /* 148-byte string literal not displayed */
OAuthProviderConfig
}
OAuth provider
func (OAuth) ExchangeCode ¶
ExchangeCode exchanges the given redirect uri and code for a token
func (OAuth) GetLoginURL ¶
GetLoginURL provides the login url for the given redirect uri and state
type OAuthProviderConfig ¶
type OAuthProviderConfig struct {
Scopes []string `long:"scope" env:"SCOPE" env-delim:"," default:"profile" default:"email" description:"Scopes"`
Prompt string `long:"prompt" env:"PROMPT" description:"Optional prompt query"`
Resource string `long:"resource" env:"RESOURCE" description:"Optional resource indicator"`
Config *oauth2.Config
// contains filtered or unexported fields
}
OAuthProviderConfig is a provider using the oauth2 library
func (*OAuthProviderConfig) ConfigCopy ¶
func (p *OAuthProviderConfig) ConfigCopy(redirectURI string) oauth2.Config
ConfigCopy returns a copy of the oauth2 config with the given redirectURI which ensures the underlying config is not modified
func (*OAuthProviderConfig) OAuthExchangeCode ¶
func (p *OAuthProviderConfig) OAuthExchangeCode(redirectURI, code string) (*oauth2.Token, error)
OAuthExchangeCode provides a base "ExchangeCode" for proiders using OAauth2
func (*OAuthProviderConfig) OAuthGetLoginURL ¶
func (p *OAuthProviderConfig) OAuthGetLoginURL(redirectURI, state string, forcePrompt bool) string
OAuthGetLoginURL provides a base "GetLoginURL" for proiders using OAauth2
type OIDC ¶
type OIDC struct {
IssuerURL string `long:"issuer-url" env:"ISSUER_URL" description:"Issuer URL"`
ClientID string `long:"client-id" env:"CLIENT_ID" description:"Client ID"`
ClientIDFile string `long:"client-id-file" env:"CLIENT_ID_FILE" description:"Path to a file containing the client id"`
ClientSecret string `long:"client-secret" env:"CLIENT_SECRET" description:"Client Secret" json:"-"`
ClientSecretFile string `long:"client-secret-file" env:"CLIENT_SECRET_FILE" description:"Path to a file containing the client secret"`
OAuthProviderConfig
// contains filtered or unexported fields
}
OIDC provider
func (OIDC) ExchangeCode ¶
ExchangeCode exchanges the given redirect uri and code for a token
func (OIDC) GetLoginURL ¶
GetLoginURL provides the login url for the given redirect uri and state
type Provider ¶
type Provider interface {
Name() string
GetLoginURL(redirectURI, state string, forcePrompt bool) string
ExchangeCode(redirectURI, code string) (string, error)
GetUser(token, UserPath string) (string, error)
Setup() error
}
Provider is used to authenticate users