bouncer/internal/proxy/director/layer/authn/oidc/options.go
William Petit d5fed4c2ac
Some checks reported errors
Cadoles/bouncer/pipeline/head Something is wrong with the build of this commit
feat(authn): add templatized error page
ref CNOUS/mse#3907
2024-06-05 15:53:17 +02:00

49 lines
960 B
Go

package oidc
import (
"net/http"
"time"
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/authn"
)
type Options struct {
HTTPTransport *http.Transport
HTTPClientTimeout time.Duration
AuthnOptions []authn.OptionFunc
}
type OptionFunc func(opts *Options)
func WithHTTPTransport(transport *http.Transport) OptionFunc {
return func(opts *Options) {
opts.HTTPTransport = transport
}
}
func WithHTTPClientTimeout(timeout time.Duration) OptionFunc {
return func(opts *Options) {
opts.HTTPClientTimeout = timeout
}
}
func WithAuthnOptions(funcs ...authn.OptionFunc) OptionFunc {
return func(opts *Options) {
opts.AuthnOptions = funcs
}
}
func NewOptions(funcs ...OptionFunc) *Options {
opts := &Options{
HTTPTransport: http.DefaultTransport.(*http.Transport),
HTTPClientTimeout: 30 * time.Second,
AuthnOptions: make([]authn.OptionFunc, 0),
}
for _, fn := range funcs {
fn(opts)
}
return opts
}