feat: cache oidc.Provider to reduce pressure on OIDC identity provider (#47)
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -8,9 +8,10 @@ import (
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
HTTPTransport *http.Transport
|
||||
HTTPClientTimeout time.Duration
|
||||
AuthnOptions []authn.OptionFunc
|
||||
HTTPTransport *http.Transport
|
||||
HTTPClientTimeout time.Duration
|
||||
AuthnOptions []authn.OptionFunc
|
||||
OIDCProviderCacheTimeout time.Duration
|
||||
}
|
||||
|
||||
type OptionFunc func(opts *Options)
|
||||
@ -33,11 +34,18 @@ func WithAuthnOptions(funcs ...authn.OptionFunc) OptionFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func WithOIDCProviderCacheTimeout(timeout time.Duration) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.OIDCProviderCacheTimeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
func NewOptions(funcs ...OptionFunc) *Options {
|
||||
opts := &Options{
|
||||
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
||||
HTTPClientTimeout: 30 * time.Second,
|
||||
AuthnOptions: make([]authn.OptionFunc, 0),
|
||||
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
||||
HTTPClientTimeout: 30 * time.Second,
|
||||
AuthnOptions: make([]authn.OptionFunc, 0),
|
||||
OIDCProviderCacheTimeout: time.Hour,
|
||||
}
|
||||
|
||||
for _, fn := range funcs {
|
||||
|
Reference in New Issue
Block a user