Documentation
¶
Index ¶
- Constants
- Variables
- type AuthCodeExchangeOption
- type AuthCodeExchangeOptions
- type AuthCodeURLOption
- type AuthCodeURLOptions
- type ClientCredentialsOption
- type ClientCredentialsOptions
- type FactoryFunc
- type OptionError
- type PrivateOperations
- type Provider
- type PublicOperations
- type RefreshTokenOption
- type RefreshTokenOptions
- type Registry
- func (r *Registry) MustRegister(name string, factory FactoryFunc)
- func (r *Registry) New(ctx context.Context, name string, opts map[string]string) (Provider, error)
- func (r *Registry) NewAt(ctx context.Context, name string, vsn int, opts map[string]string) (Provider, error)
- func (r *Registry) Register(name string, factory FactoryFunc) error
- type Token
- type WithProviderOptions
- func (wpo WithProviderOptions) ApplyToAuthCodeExchangeOptions(target *AuthCodeExchangeOptions)
- func (wpo WithProviderOptions) ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
- func (wpo WithProviderOptions) ApplyToClientCredentialsOptions(target *ClientCredentialsOptions)
- func (wpo WithProviderOptions) ApplyToRefreshTokenOptions(target *RefreshTokenOptions)
- type WithRedirectURL
- type WithScopes
- type WithURLParams
Constants ¶
const VersionLatest = -1
Variables ¶
var ( ErrNoSuchProvider = errors.New("no provider with the given name") ErrNoProviderWithVersion = errors.New("version not supported") ErrNoOptions = errors.New("options provided but none accepted") )
var ( ErrOIDCMissingIDToken = errors.New("oidc: missing ID token in response") ErrOIDCNonceMismatch = errors.New("oidc: nonce does not match") )
var GlobalRegistry = NewRegistry()
Functions ¶
This section is empty.
Types ¶
type AuthCodeExchangeOption ¶ added in v1.9.0
type AuthCodeExchangeOption interface {
ApplyToAuthCodeExchangeOptions(target *AuthCodeExchangeOptions)
}
type AuthCodeExchangeOptions ¶ added in v1.9.0
type AuthCodeExchangeOptions struct {
RedirectURL string
AuthCodeOptions []oauth2.AuthCodeOption
ProviderOptions map[string]string
}
AuthCodeExchangeOptions are options for the AuthCodeExchange operation.
func (*AuthCodeExchangeOptions) ApplyOptions ¶ added in v1.9.0
func (o *AuthCodeExchangeOptions) ApplyOptions(opts []AuthCodeExchangeOption)
type AuthCodeURLOption ¶ added in v1.9.0
type AuthCodeURLOption interface {
ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
}
type AuthCodeURLOptions ¶ added in v1.9.0
type AuthCodeURLOptions struct {
RedirectURL string
Scopes []string
AuthCodeOptions []oauth2.AuthCodeOption
ProviderOptions map[string]string
}
AuthCodeURLOptions are options for the AuthCodeURL operation.
func (*AuthCodeURLOptions) ApplyOptions ¶ added in v1.9.0
func (o *AuthCodeURLOptions) ApplyOptions(opts []AuthCodeURLOption)
type ClientCredentialsOption ¶ added in v1.9.0
type ClientCredentialsOption interface {
ApplyToClientCredentialsOptions(target *ClientCredentialsOptions)
}
type ClientCredentialsOptions ¶ added in v1.9.0
type ClientCredentialsOptions struct {
Scopes []string
EndpointParams url.Values
ProviderOptions map[string]string
}
ClientCredentialsOptions are options for the ClientCredentials operation.
func (*ClientCredentialsOptions) ApplyOptions ¶ added in v1.9.0
func (o *ClientCredentialsOptions) ApplyOptions(opts []ClientCredentialsOption)
type FactoryFunc ¶
func BasicFactory ¶ added in v1.8.0
func BasicFactory(endpoint oauth2.Endpoint) FactoryFunc
type OptionError ¶
func (*OptionError) Error ¶
func (oe *OptionError) Error() string
func (*OptionError) Unwrap ¶ added in v1.9.0
func (oe *OptionError) Unwrap() error
type PrivateOperations ¶ added in v1.9.0
type PrivateOperations interface {
PublicOperations
// AuthCodeExchange performs an authorization code flow exchange request.
AuthCodeExchange(ctx context.Context, code string, opts ...AuthCodeExchangeOption) (*Token, error)
// RefreshToken performs a refresh token flow request.
RefreshToken(ctx context.Context, t *Token, opts ...RefreshTokenOption) (*Token, error)
// ClientCredentials performs a client credentials flow request.
ClientCredentials(ctx context.Context, opts ...ClientCredentialsOption) (*Token, error)
}
PrivateOperations defines the operations for a client that require knowledge of the client ID and client secret.
type Provider ¶
type Provider interface {
// Version is the revision of this provider vis-a-vis the options it
// supports.
Version() int
// Public returns a view of the operations for this provider for the given
// client ID.
Public(clientID string) PublicOperations
// Private returns a complete set of the operations for this provider for
// the given client ID and client secret.
Private(clientID, clientSecret string) PrivateOperations
}
Provider represents an integration with a particular OAuth provider using the authorization code grant.
func AzureADFactory ¶ added in v1.8.0
func CustomFactory ¶ added in v1.8.0
type PublicOperations ¶ added in v1.9.0
type PublicOperations interface {
AuthCodeURL(state string, opts ...AuthCodeURLOption) (string, bool)
}
PublicOperations defines the operations for a client that only require knowledge of the client ID.
type RefreshTokenOption ¶ added in v1.9.0
type RefreshTokenOption interface {
ApplyToRefreshTokenOptions(target *RefreshTokenOptions)
}
type RefreshTokenOptions ¶ added in v1.9.0
RefreshTokenOptions are options for the RefreshToken operation.
func (*RefreshTokenOptions) ApplyOptions ¶ added in v1.9.0
func (o *RefreshTokenOptions) ApplyOptions(opts []RefreshTokenOption)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) MustRegister ¶
func (r *Registry) MustRegister(name string, factory FactoryFunc)
func (*Registry) New ¶
New looks up a provider with the given name and configures it according to the specified options.
type Token ¶ added in v1.8.0
type Token struct {
*oauth2.Token `json:",inline"`
ExtraData map[string]interface{} `json:"extra_data,omitempty"`
}
Token is an extension of *oauth2.Token that also provides complementary data to store (usually from the token's own raw data).
type WithProviderOptions ¶ added in v1.9.0
func (WithProviderOptions) ApplyToAuthCodeExchangeOptions ¶ added in v1.9.0
func (wpo WithProviderOptions) ApplyToAuthCodeExchangeOptions(target *AuthCodeExchangeOptions)
func (WithProviderOptions) ApplyToAuthCodeURLOptions ¶ added in v1.9.0
func (wpo WithProviderOptions) ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
func (WithProviderOptions) ApplyToClientCredentialsOptions ¶ added in v1.9.0
func (wpo WithProviderOptions) ApplyToClientCredentialsOptions(target *ClientCredentialsOptions)
func (WithProviderOptions) ApplyToRefreshTokenOptions ¶ added in v1.9.0
func (wpo WithProviderOptions) ApplyToRefreshTokenOptions(target *RefreshTokenOptions)
type WithRedirectURL ¶ added in v1.9.0
type WithRedirectURL string
func (WithRedirectURL) ApplyToAuthCodeExchangeOptions ¶ added in v1.9.0
func (wru WithRedirectURL) ApplyToAuthCodeExchangeOptions(target *AuthCodeExchangeOptions)
func (WithRedirectURL) ApplyToAuthCodeURLOptions ¶ added in v1.9.0
func (wru WithRedirectURL) ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
type WithScopes ¶ added in v1.9.0
type WithScopes []string
func (WithScopes) ApplyToAuthCodeURLOptions ¶ added in v1.9.0
func (ws WithScopes) ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
func (WithScopes) ApplyToClientCredentialsOptions ¶ added in v1.9.0
func (ws WithScopes) ApplyToClientCredentialsOptions(target *ClientCredentialsOptions)
type WithURLParams ¶ added in v1.9.0
func (WithURLParams) ApplyToAuthCodeExchangeOptions ¶ added in v1.9.0
func (wup WithURLParams) ApplyToAuthCodeExchangeOptions(target *AuthCodeExchangeOptions)
func (WithURLParams) ApplyToAuthCodeURLOptions ¶ added in v1.9.0
func (wup WithURLParams) ApplyToAuthCodeURLOptions(target *AuthCodeURLOptions)
func (WithURLParams) ApplyToClientCredentialsOptions ¶ added in v1.9.0
func (wup WithURLParams) ApplyToClientCredentialsOptions(target *ClientCredentialsOptions)