oauth2

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDeviceCodeFlow

func NewDeviceCodeFlow(prompter Prompter) func(c *Client) (Initiator, error)

func NewLegacyDeviceCodeFlow

func NewLegacyDeviceCodeFlow(prompter Prompter) func(c *Client) (Initiator, error)

Types

type Client

type Client struct {
	Configuration OpenIDConfiguration
	Tx            *http.Transport
	ClientId      string
	Resource      string
	Scope         string
	TokenStore    TokenStore
	Flow          InitiatorFactory
	// contains filtered or unexported fields
}

func NewClient

func NewClient(tx *http.Transport, clientId string, options ...ClientOptionFunc) (*Client, error)

func (*Client) FetchTokens

func (c *Client) FetchTokens(ctx context.Context, failOnRefreshFailure bool) (*Tokens, error)

func (*Client) RefreshTokens

func (c *Client) RefreshTokens(ctx context.Context, t *Tokens) (*Tokens, error)

type ClientOptionFunc

type ClientOptionFunc func(*Client) (*Client, error)

func WithConfigurationFromWellknown

func WithConfigurationFromWellknown(url string, placeholders map[string]string) ClientOptionFunc

func WithConfigurationOverrides

func WithConfigurationOverrides(config OpenIDConfiguration) ClientOptionFunc

func WithFlow

func WithFlow(flow InitiatorFactory) ClientOptionFunc

func WithNowGetter

func WithNowGetter(nowGetter func() time.Time) ClientOptionFunc

func WithResource

func WithResource(resource string) ClientOptionFunc

func WithTokenStore

func WithTokenStore(store TokenStore) ClientOptionFunc

type DeviceCodeFlowInitiator

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

func (*DeviceCodeFlowInitiator) DisplayName

func (*DeviceCodeFlowInitiator) DisplayName() string

func (*DeviceCodeFlowInitiator) Initiate

func (i *DeviceCodeFlowInitiator) Initiate(ctx context.Context) (*Tokens, error)

type DurationInSeconds

type DurationInSeconds time.Duration

func (*DurationInSeconds) UnmarshalJSON

func (i *DurationInSeconds) UnmarshalJSON(b []byte) error

type ErrTokenExpired

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

func (*ErrTokenExpired) Error

func (e *ErrTokenExpired) Error() string

type ErrTokenStoreContentBroken

type ErrTokenStoreContentBroken struct{}

func (*ErrTokenStoreContentBroken) Error

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type Initiator

type Initiator interface {
	DisplayName() string
	Initiate(context.Context) (*Tokens, error)
}

type InitiatorFactory

type InitiatorFactory func(*Client) (Initiator, error)

type OpenIDConfiguration

type OpenIDConfiguration struct {
	AuthorizationEndpoint             string   `json:"authorization_endpoint"`
	ClaimsSupported                   []string `json:"claims_supported,omitempty"`
	CloudGraphHostName                string   `json:"cloud_graph_host_name,omitempty"`
	CloudInstanceName                 string   `json:"cloud_instance_name,omitempty"`
	DeviceAuthorizationEndpoint       string   `json:"device_authorization_endpoint,omitempty"`
	EndSessionEndpoint                string   `json:"end_session_endpoint,omitempty"`
	FrontchannelLogoutSupported       bool     `json:"frontchannel_logout_supported,omitempty"`
	HttpLogoutSupported               bool     `json:"http_logout_supported,omitempty"`
	IdTokenSigningAlgValuesSupported  []string `json:"id_token_signing_alg_values_supported,omitempty"`
	Issuer                            string   `json:"issuer,omitempty"`
	JwksUri                           string   `json:"jwks_uri,omitempty"`
	KerberosEndpoint                  string   `json:"kerberos_endpoint,omitempty"`
	MsgraphHost                       string   `json:"msgraph_host,omitempty"`
	RbacUrl                           string   `json:"rbac_url,omitempty"`
	RequestUriParameterSupported      bool     `json:"request_uri_parameter_supported,omitempty"`
	ResponseModesSupported            []string `json:"response_modes_supported,omitempty"`
	ResponseTypesSupported            []string `json:"response_types_supported,omitempty"`
	ScopesSupported                   []string `json:"scopes_supported,omitempty"`
	SubjectTypesSupported             []string `json:"subject_types_supported,omitempty"`
	TenantRegionScope                 string   `json:"tenant_region_scope,omitempty"`
	TokenEndpoint                     string   `json:"token_endpoint,omitempty"`
	TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"`
	UserinfoEndpoint                  string   `json:"userinfo_endpoint,omitempty"`
}

type Prompter

type Prompter func(msg string) error

type SimpleTokenStore

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

func NewSimpleTokenStore

func NewSimpleTokenStore(path string, authority string, nowGetter func() time.Time) *SimpleTokenStore

func (*SimpleTokenStore) Fetch

func (s *SimpleTokenStore) Fetch(ctx context.Context) (*Tokens, error)

func (*SimpleTokenStore) Store

func (s *SimpleTokenStore) Store(ctx context.Context, t *Tokens) error

type TokenEndpointResponse

type TokenEndpointResponse struct {
	TokenType    string            `json:"token_type"`
	AccessToken  string            `json:"access_token"`
	RefreshToken string            `json:"refresh_token,omitempty"`
	IdToken      string            `json:"id_token,omitempty"`
	Scope        string            `json:"scope,omitempty"`
	ExpiresIn    DurationInSeconds `json:"expires_in,omitempty"`
}

type TokenStore

type TokenStore interface {
	Store(ctx context.Context, cred *Tokens) error
	Fetch(ctx context.Context) (*Tokens, error)
}

type Tokens

type Tokens struct {
	TokenType    string    `json:"tokenType"`
	AccessToken  string    `json:"accessToken"`
	RefreshToken string    `json:"refreshToken,omitempty"`
	IdToken      string    `json:"idToken,omitempty"`
	Scope        string    `json:"scope,omitempty"`
	Resource     string    `json:"resource,omitempty"`
	ExpireOn     time.Time `json:"expireOn,omitempty"`
	Authority    string    `json:"_authority"`
}

func (*Tokens) Valid

func (creds *Tokens) Valid() bool

type TokensSet

type TokensSet []*Tokens

Jump to

Keyboard shortcuts

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