oauthutils

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface that models *http.Client.

type OauthDiscovery

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

OauthDiscovery is an implementation of OauthLocationGetter which calls a known URL to get the parameters

func NewOauthDiscovery

func NewOauthDiscovery(client HTTPClient) *OauthDiscovery

NewOauthDiscovery creates a new OauthDiscovery

func (OauthDiscovery) Discover

func (d OauthDiscovery) Discover(ctx context.Context, discoveryURL string) (*OauthDiscoveryResult, error)

Discover starts the OAuth discovery and eventually returns the results

type OauthDiscoveryMock

type OauthDiscoveryMock struct {
	DiscoverFn func(context.Context, string) (*OauthDiscoveryResult, error)
}

OauthDiscoveryMock is an implementation of OauthLocationGetter usable as a mock implementation in tests

func (*OauthDiscoveryMock) Discover

func (o *OauthDiscoveryMock) Discover(ctx context.Context, discoveryURL string) (*OauthDiscoveryResult, error)

Discover calls the mocked function of the OauthDiscoveryMock

type OauthDiscoveryResult

type OauthDiscoveryResult struct {
	Issuer                 string   `json:"issuer"`
	AuthorizationEndpoint  string   `json:"authorization_endpoint"`
	TokenEndpoint          string   `json:"token_endpoint"`
	UserinfoEndpoint       string   `json:"userinfo_endpoint"`
	EndSessionEndpoint     string   `json:"end_session_endpoint"`
	ResponseTypesSupported []string `json:"response_types_supported"`
	GrantTypesSupported    []string `json:"grant_types_supported"`
	JwksURI                string   `json:"jwks_uri"`
	IntrospectionEndpoint  string   `json:"introspection_endpoint"`
}

OauthDiscoveryResult is the result of a OauthLocation discovery call and contains all the parameters usable for a following oauth flow

type OauthLocationGetter

type OauthLocationGetter interface {
	// Discover is responsible for determining the parameters used for an oauth flow
	// and returns them as a OauthDiscoveryResult
	Discover(ctx context.Context, discoveryURL string) (*OauthDiscoveryResult, error)
}

OauthLocationGetter is used to get the location parameters used in an oauth flow

type StaticOauthDiscovery

type StaticOauthDiscovery struct {
	DiscoveryValues *OauthDiscoveryResult
}

StaticOauthDiscovery has a static/hard-coded set of oauth parameters and does not actually do a discovery call to get the parameters but just returns the hard-coded values as OauthDiscoveryResult

func (StaticOauthDiscovery) Discover

func (d StaticOauthDiscovery) Discover(ctx context.Context, discoveryURL string) (*OauthDiscoveryResult, error)

Discover tries to determine the parameters used for an oauth flow and returns them as a OauthDiscoveryResult

Jump to

Keyboard shortcuts

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