provider

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const VersionLatest = -1

Variables

View Source
var (
	ErrNoSuchProvider        = errors.New("provider: no provider with the given name")
	ErrNoProviderWithVersion = errors.New("provider: version not supported")
	ErrNoOptions             = errors.New("provider: options provided but none accepted")
)
View Source
var (
	ErrOIDCMissingIDToken = errors.New("provider: oidc: missing ID token in response")
	ErrOIDCNonceMismatch  = errors.New("provider: oidc: nonce does not match")
)
View Source
var GlobalRegistry = NewRegistry()

Functions

This section is empty.

Types

type AuthCodeURLConfig

type AuthCodeURLConfig interface {
	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
}

AuthCodeURLConfig is the component of *oauth2.Config required for generating authorization code URLs.

type AuthCodeURLConfigBuilder

type AuthCodeURLConfigBuilder interface {
	// WithRedirectURL sets the redirect URL for the config.
	WithRedirectURL(redirectURL string) AuthCodeURLConfigBuilder

	// WithScopes sets the scopes for the config.
	WithScopes(scopes ...string) AuthCodeURLConfigBuilder

	// Build creates an AuthCodeURLConfig from the current configuration.
	Build() AuthCodeURLConfig
}

AuthCodeURLConfigBuilder creates AuthCodeURLConfigs.

type ConformingAuthCodeURLConfigBuilder added in v1.8.0

type ConformingAuthCodeURLConfigBuilder struct {
	// contains filtered or unexported fields
}

func NewConformingAuthCodeURLConfigBuilder added in v1.8.0

func NewConformingAuthCodeURLConfigBuilder(endpoint oauth2.Endpoint, clientID string) *ConformingAuthCodeURLConfigBuilder

func (*ConformingAuthCodeURLConfigBuilder) Build added in v1.8.0

func (*ConformingAuthCodeURLConfigBuilder) WithRedirectURL added in v1.8.0

func (cb *ConformingAuthCodeURLConfigBuilder) WithRedirectURL(redirectURL string) AuthCodeURLConfigBuilder

func (*ConformingAuthCodeURLConfigBuilder) WithScopes added in v1.8.0

type ExchangeConfig

type ExchangeConfig interface {
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*Token, error)
	Refresh(ctx context.Context, t *Token) (*Token, error)
}

ExchangeConfig is the component of *oauth2.Config required to exchange an authorization code for a token.

type ExchangeConfigBuilder

type ExchangeConfigBuilder interface {
	// WithOption sets an exchange-specific option for this provider. If the
	// provider does not support the given option, it is ignored.
	WithOption(name, value string) ExchangeConfigBuilder

	// WithRedirectURL sets the redirect URL for the config.
	WithRedirectURL(redirectURL string) ExchangeConfigBuilder

	// Build creates an ExchangeConfig from the current configuration.
	Build() ExchangeConfig
}

ExchangeConfigBuilder creates ExchangeConfigs.

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
}

func (*OptionError) Error

func (oe *OptionError) Error() string

type Provider

type Provider interface {
	// Version is the revision of this provider vis-a-vis the options it
	// supports.
	Version() int

	// NewAuthCodeURLConfigBuilder creates a config builder automatically scoped
	// to this provider with the specified options.
	NewAuthCodeURLConfigBuilder(clientID string) AuthCodeURLConfigBuilder

	// NewExchangeConfigBuilder creates a new config builder for token exchange.
	NewExchangeConfigBuilder(clientID, clientSecret string) ExchangeConfigBuilder
}

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

Jump to

Keyboard shortcuts

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