Documentation
¶
Index ¶
- Constants
- Variables
- func IsRefreshNeed(accessToken string) (bool, error)
- type InfProvider
- type InfProviderExtra
- type IntrospectJWTKey
- type Noop
- func (Noop) ClientConfig() (*clientcredentials.Config, error)
- func (Noop) GetAuthURL() string
- func (Noop) GetAuthURLExternal() string
- func (Noop) GetCertURL() string
- func (Noop) GetClientID() string
- func (Noop) GetClientIDExternal() string
- func (Noop) GetClientSecret() string
- func (Noop) GetClientSecretExternal() string
- func (Noop) GetIntrospectURL() string
- func (Noop) GetScopes() []string
- func (Noop) GetTokenURL() string
- func (Noop) GetTokenURLExternal() string
- func (Noop) IsNoop() bool
- func (Noop) JWTKeyFunc(opts ...jwks.OptionJWK) (models.InfKeyFuncParser, error)
- func (Noop) NewOauth2Shared(_ context.Context) (*OAuth2Shared, error)
- func (Noop) RoundTripper(_ context.Context, transport http.RoundTripper) (http.RoundTripper, error)
- func (Noop) RoundTripperWrapper(_ *clientcredentials.Config) func(_ context.Context, transport http.RoundTripper) http.RoundTripper
- type NoopJWTKey
- type OAuth2Shared
- type Oauth2Transport
- type OptionActiveProvider
- type Provider
- type ProviderExtra
- func (p *ProviderExtra) IsNoop() bool
- func (p *ProviderExtra) JWTKeyFunc(opts ...jwks.OptionJWK) (models.InfKeyFuncParser, error)
- func (p *ProviderExtra) NewOauth2Shared(ctx context.Context) (*OAuth2Shared, error)
- func (p *ProviderExtra) RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
- func (p *ProviderExtra) RoundTripperWrapper(cfg *clientcredentials.Config) func(ctx context.Context, transport http.RoundTripper) http.RoundTripper
- type RestIntrospect
- type Token
Constants ¶
const ( ProviderKeycloakKey = "keycloak" ProviderGenericKey = "generic" ProviderNoopKey = "noop" )
const NoopKey = "noop"
Variables ¶
var DefaultExpireDuration = time.Second * 10
DefaultExpireDuration is the default duration to check if the access token is about to expire.
var IntrospectKey = "introspect"
Functions ¶
func IsRefreshNeed ¶ added in v0.4.1
IsRefreshNeed checks if the access token is about to expire.
Types ¶
type InfProvider ¶ added in v0.4.0
type InfProvider interface {
ClientConfig() (*clientcredentials.Config, error)
GetCertURL() string
GetTokenURL() string
GetTokenURLExternal() string
GetAuthURL() string
GetAuthURLExternal() string
GetClientID() string
GetClientIDExternal() string
GetClientSecret() string
GetClientSecretExternal() string
GetScopes() []string
GetIntrospectURL() string
}
type InfProviderExtra ¶ added in v0.4.0
type InfProviderExtra interface {
InfProvider
// JWTKeyFunc returns the JWT key used to verify the token.
JWTKeyFunc(opts ...jwks.OptionJWK) (models.InfKeyFuncParser, error)
IsNoop() bool
RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
RoundTripperWrapper(cfg *clientcredentials.Config) func(ctx context.Context, transport http.RoundTripper) http.RoundTripper
}
type IntrospectJWTKey ¶ added in v0.4.8
type IntrospectJWTKey struct {
URL string
ClientID string
ClientSecret string
Client *http.Client
Ctx context.Context
}
func (IntrospectJWTKey) CheckIntrospect ¶ added in v0.4.8
func (i IntrospectJWTKey) CheckIntrospect(token string) error
func (IntrospectJWTKey) Keyfunc ¶ added in v0.4.8
func (IntrospectJWTKey) Keyfunc(token *jwt.Token) (interface{}, error)
func (IntrospectJWTKey) ParseWithClaims ¶ added in v0.7.0
type Noop ¶ added in v0.4.0
type Noop struct{}
func (Noop) ClientConfig ¶ added in v0.4.0
func (Noop) ClientConfig() (*clientcredentials.Config, error)
func (Noop) GetAuthURL ¶ added in v0.4.0
func (Noop) GetAuthURLExternal ¶ added in v0.5.0
func (Noop) GetCertURL ¶ added in v0.4.0
func (Noop) GetClientID ¶ added in v0.4.0
func (Noop) GetClientIDExternal ¶ added in v0.5.0
func (Noop) GetClientSecret ¶ added in v0.4.0
func (Noop) GetClientSecretExternal ¶ added in v0.5.0
func (Noop) GetIntrospectURL ¶ added in v0.4.8
func (Noop) GetTokenURL ¶ added in v0.4.0
func (Noop) GetTokenURLExternal ¶ added in v0.5.0
func (Noop) JWTKeyFunc ¶ added in v0.4.0
func (Noop) NewOauth2Shared ¶ added in v0.6.3
func (Noop) NewOauth2Shared(_ context.Context) (*OAuth2Shared, error)
func (Noop) RoundTripper ¶ added in v0.4.2
func (Noop) RoundTripper(_ context.Context, transport http.RoundTripper) (http.RoundTripper, error)
func (Noop) RoundTripperWrapper ¶ added in v0.4.5
func (Noop) RoundTripperWrapper(_ *clientcredentials.Config) func(_ context.Context, transport http.RoundTripper) http.RoundTripper
type NoopJWTKey ¶ added in v0.4.0
type NoopJWTKey struct{}
func (NoopJWTKey) EndBackground ¶ added in v0.4.0
func (NoopJWTKey) EndBackground()
func (NoopJWTKey) Keyfunc ¶ added in v0.4.0
func (NoopJWTKey) Keyfunc(_ *jwt.Token) (interface{}, error)
func (NoopJWTKey) ParseWithClaims ¶ added in v0.7.0
type OAuth2Shared ¶ added in v0.6.3
type OAuth2Shared struct {
}
func (OAuth2Shared) RoundTripper ¶ added in v0.6.3
func (o OAuth2Shared) RoundTripper(_ context.Context, transport http.RoundTripper) (http.RoundTripper, error)
RoundTripper returns a new RoundTripper that adds an OAuth2 Transport.
If Source is nil, returns transport as-is.
type Oauth2Transport ¶ added in v0.5.1
Oauth2Transport wraps oauth2.Transport to suspend CancelRequest.
type OptionActiveProvider ¶ added in v0.4.0
type OptionActiveProvider func(options *optionsActiveProvider)
func WithActive ¶ added in v0.6.2
func WithActive(provider string) OptionActiveProvider
func WithNoop ¶ added in v0.4.0
func WithNoop(v bool) OptionActiveProvider
WithNoop sets the active provider to noop.
type Provider ¶
type Provider struct {
// Active is the name of the active provider, if empty the first provider is used.
//
// If set to "noop" the Noop provider is used.
Active string `cfg:"active"`
Keycloak *providers.KeyCloak `cfg:"keycloak"`
Generic *providers.Generic `cfg:"generic"`
}
func (*Provider) ActiveProvider ¶
func (p *Provider) ActiveProvider(opts ...OptionActiveProvider) (ret InfProviderExtra)
ActiveProvider returns the active provider or the first provider if none is active.
Returns nil if no provider is configured.
func (Provider) SetActiveProvider ¶
SetActiveProvider return the provider with the given name as active without modifying the original provider.
type ProviderExtra ¶ added in v0.4.0
type ProviderExtra struct {
InfProvider
// contains filtered or unexported fields
}
func (*ProviderExtra) IsNoop ¶ added in v0.4.0
func (p *ProviderExtra) IsNoop() bool
func (*ProviderExtra) JWTKeyFunc ¶ added in v0.4.0
func (p *ProviderExtra) JWTKeyFunc(opts ...jwks.OptionJWK) (models.InfKeyFuncParser, error)
JWTKeyFunc returns a jwt.Keyfunc.
Need GetCertURL in provider.
If introspect is true, the introspect endpoint is used to verify the token. Use Parser function for introspect, not keyfunc.
func (*ProviderExtra) NewOauth2Shared ¶ added in v0.6.3
func (p *ProviderExtra) NewOauth2Shared(ctx context.Context) (*OAuth2Shared, error)
func (*ProviderExtra) RoundTripper ¶ added in v0.4.2
func (p *ProviderExtra) RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
RoundTripper returns a new RoundTripper that adds an OAuth2 Transport.
Uses provider's ClientConfig.
func (*ProviderExtra) RoundTripperWrapper ¶ added in v0.4.5
func (p *ProviderExtra) RoundTripperWrapper(cfg *clientcredentials.Config) func(ctx context.Context, transport http.RoundTripper) http.RoundTripper
type RestIntrospect ¶ added in v0.4.8
type RestIntrospect struct {
Active bool `json:"active"`
}