William Petit
d5fed4c2ac
Some checks reported errors
Cadoles/bouncer/pipeline/head Something is wrong with the build of this commit
ref CNOUS/mse#3907
49 lines
960 B
Go
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
|
|
}
|