provider

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const VersionLatest = -1

Variables

View Source
var (
	ErrNoSuchProvider        = errors.New("no provider with the given name")
	ErrNoProviderWithVersion = errors.New("version not supported")
	ErrNoOptions             = errors.New("options provided but none accepted")
)
View Source
var (
	ErrOIDCMissingIDToken = errors.New("oidc: missing ID token in response")
	ErrOIDCNonceMismatch  = errors.New("oidc: nonce does not match")
)
View Source
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

type FactoryFunc func(ctx context.Context, vsn int, opts map[string]string) (Provider, error)

func BasicFactory added in v1.8.0

func BasicFactory(endpoint oauth2.Endpoint) FactoryFunc

type OptionError

type OptionError struct {
	Option  string
	Message string
	Cause   error
}

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 AzureADFactory(ctx context.Context, vsn int, opts map[string]string) (Provider, error)

func CustomFactory added in v1.8.0

func CustomFactory(ctx context.Context, vsn int, opts map[string]string) (Provider, error)

func OIDCFactory added in v1.8.0

func OIDCFactory(ctx context.Context, vsn int, opts map[string]string) (Provider, error)

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

type RefreshTokenOptions struct {
	ProviderOptions map[string]string
}

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

func (r *Registry) New(ctx context.Context, name string, opts map[string]string) (Provider, error)

New looks up a provider with the given name and configures it according to the specified options.

func (*Registry) NewAt

func (r *Registry) NewAt(ctx context.Context, name string, vsn int, opts map[string]string) (Provider, error)

NewAt looks up a provider with the given name at the given version and configures it according to the specified options.

func (*Registry) Register

func (r *Registry) Register(name string, factory FactoryFunc) error

Register registers a new provider using the name and factory specified.

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

type WithProviderOptions map[string]string

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

type WithURLParams map[string]string

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL