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(ctx context.Context, opts ...OptionJWK) (InfJWTKeyFunc, error)
- type NoopJWTKey
- type OptionActiveProvider
- type OptionJWK
- type Provider
- func (p *Provider) ActiveProvider(opts ...OptionActiveProvider) (ret InfProviderExtra)
- func (p *Provider) RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
- func (p *Provider) RoundTripperMust(ctx context.Context, transport http.RoundTripper) http.RoundTripper
- func (p Provider) SetActiveProvider(name string) *Provider
- type ProviderExtra
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(ctx context.Context, opts ...OptionJWK) (InfJWTKeyFunc, error)
IsNoop() bool
}
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
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 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 ¶
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) RoundTripper ¶
func (p *Provider) RoundTripper(ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)
RoundTripper returns a new RoundTripper that adds an OAuth2 Transport.
Uses active provider's ClientConfig.
func (*Provider) RoundTripperMust ¶
func (p *Provider) RoundTripperMust(ctx context.Context, transport http.RoundTripper) http.RoundTripper
RoundTripperMust panic if RoundTripper return error.
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(ctx context.Context, opts ...OptionJWK) (InfJWTKeyFunc, error)
JWTKeyFunc returns a jwt.Keyfunc.
Need GetCertURL in provider.