Documentation
¶
Index ¶
- Variables
- func IsRefreshNeed(accessToken string) (bool, error)
- type InfJWTKeyFunc
- type InfProvider
- type InfProviderExtra
- type JWTKeyFunc
- type Noop
- func (Noop) ClientConfig() (*clientcredentials.Config, error)
- func (Noop) GetAuthURL() string
- func (Noop) GetCertURL() string
- func (Noop) GetClientID() string
- func (Noop) GetClientSecret() string
- func (Noop) GetTokenURL() string
- func (Noop) IsNoop() bool
- func (Noop) JWTKeyFunc(opts ...OptionJWK) (InfJWTKeyFunc, error)
- func (Noop) RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
- func (Noop) RoundTripperWrapper(_ *clientcredentials.Config) func(_ context.Context, transport http.RoundTripper) http.RoundTripper
- type NoopJWTKey
- type OptionActiveProvider
- type OptionJWK
- type Provider
- type ProviderExtra
- func (p *ProviderExtra) IsNoop() bool
- func (p *ProviderExtra) JWTKeyFunc(opts ...OptionJWK) (InfJWTKeyFunc, 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
Constants ¶
This section is empty.
Variables ¶
var DefaultExpireDuration = time.Second * 10
DefaultExpireDuration is the default duration to check if the access token is about to expire.
var ErrTokenInvalid = fmt.Errorf("token is invalid")
Functions ¶
func IsRefreshNeed ¶ added in v0.4.1
IsRefreshNeed checks if the access token is about to expire.
Types ¶
type InfJWTKeyFunc ¶ added in v0.4.0
type InfProvider ¶ added in v0.4.0
type InfProviderExtra ¶ added in v0.4.0
type InfProviderExtra interface {
InfProvider
// JWTKeyFunc returns the JWT key used to verify the token.
JWTKeyFunc(opts ...OptionJWK) (InfJWTKeyFunc, 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 JWTKeyFunc ¶ added in v0.4.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) GetCertURL ¶ added in v0.4.0
func (Noop) GetClientID ¶ added in v0.4.0
func (Noop) GetClientSecret ¶ added in v0.4.0
func (Noop) GetTokenURL ¶ added in v0.4.0
func (Noop) JWTKeyFunc ¶ added in v0.4.0
func (Noop) JWTKeyFunc(opts ...OptionJWK) (InfJWTKeyFunc, error)
func (Noop) RoundTripper ¶ added in v0.4.2
func (Noop) RoundTripper(ctx 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()
type OptionActiveProvider ¶ added in v0.4.0
type OptionActiveProvider func(options *optionsActiveProvider)
func WithNoop ¶ added in v0.4.0
func WithNoop(v bool) OptionActiveProvider
WithNoop sets the active provider to noop.
type OptionJWK ¶
type OptionJWK func(options *optionsJWK)
func WithClient ¶ added in v0.2.2
WithClient is used to set the http.Client used to fetch the JWKs.
func WithContext ¶ added in v0.4.5
WithContext is used to set the context used to fetch the JWKs.
func WithRefreshErrorHandler ¶
WithRefreshErrorHandler sets the refresh error handler for the jwt.Key.
func WithRefreshInterval ¶ added in v0.2.0
WithRefreshInterval sets the refresh interval for the jwt.Keyfunc default is 5 minutes.
func WithRefreshUnknownKID ¶ added in v0.2.0
WithRefreshUnknownKID sets the refresh unknown KID for the jwt.Key, default is false.
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"`
}
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 ...OptionJWK) (InfJWTKeyFunc, error)
JWTKeyFunc returns a jwt.Keyfunc.
Need GetCertURL in provider.
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