provider

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 20 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 DeviceCodeAuthOption added in v1.10.0

type DeviceCodeAuthOption interface {
	ApplyToDeviceCodeAuthOptions(target *DeviceCodeAuthOptions)
}

type DeviceCodeAuthOptions added in v1.10.0

type DeviceCodeAuthOptions struct {
	Scopes          []string
	ProviderOptions map[string]string
}

DeviceCodeAuthOptions are options for the DeviceCodeAuth operation.

func (*DeviceCodeAuthOptions) ApplyOptions added in v1.10.0

func (o *DeviceCodeAuthOptions) ApplyOptions(opts []DeviceCodeAuthOption)

type DeviceCodeExchangeOption added in v1.10.0

type DeviceCodeExchangeOption interface {
	ApplyToDeviceCodeExchangeOptions(target *DeviceCodeExchangeOptions)
}

type DeviceCodeExchangeOptions added in v1.10.0

type DeviceCodeExchangeOptions struct {
	ProviderOptions map[string]string
}

DeviceCodeExchangeOptions are options for the DeviceCodeExchange operation.

func (*DeviceCodeExchangeOptions) ApplyOptions added in v1.10.0

func (o *DeviceCodeExchangeOptions) ApplyOptions(opts []DeviceCodeExchangeOption)

type Endpoint added in v1.10.0

type Endpoint struct {
	oauth2.Endpoint

	DeviceURL string
}

Endpoint is an extension of oauth2.Endpoint that also provides information about other URLs.

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 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)

	// 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 returns a URL to send a user to for initial authentication.
	//
	// If this provider does not define an authorization code endpoint URL, this
	// method returns false.
	AuthCodeURL(state string, opts ...AuthCodeURLOption) (string, bool)

	// DeviceCodeAuth performs the RFC 8628 device code authorization operation.
	//
	// If this provider does not support device code authorization, this method
	// returns false.
	DeviceCodeAuth(ctx context.Context, opts ...DeviceCodeAuthOption) (*devicecode.Auth, bool, error)

	// DeviceCodeExchange performs the RFC 8628 device code exchange operation
	// once, without polling.
	DeviceCodeExchange(ctx context.Context, deviceCode string, opts ...DeviceCodeExchangeOption) (*Token, error)

	// RefreshToken performs a refresh token flow request.
	//
	// This method does not check the expiration of the token. It forces a
	// refresh when invoked.
	//
	// Depending on the source of the token, this method may require the client
	// secret. However, for implicit and device code grants, it only requires
	// the client ID.
	RefreshToken(ctx context.Context, t *Token, opts ...RefreshTokenOption) (*Token, error)
}

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) ApplyToDeviceCodeAuthOptions added in v1.10.0

func (wpo WithProviderOptions) ApplyToDeviceCodeAuthOptions(target *DeviceCodeAuthOptions)

func (WithProviderOptions) ApplyToDeviceCodeExchangeOptions added in v1.10.0

func (wpo WithProviderOptions) ApplyToDeviceCodeExchangeOptions(target *DeviceCodeExchangeOptions)

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)

func (WithScopes) ApplyToDeviceCodeAuthOptions added in v1.10.0

func (ws WithScopes) ApplyToDeviceCodeAuthOptions(target *DeviceCodeAuthOptions)

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