package oidc import ( "context" "github.com/coreos/go-oidc/v3/oidc" ) type OptionFunc func(*Option) type Option struct { Provider *oidc.Provider ClientID string ClientSecret string RedirectURL string Scopes []string AcrValues string SkipIssuerCheck bool } func WithRedirectURL(url string) OptionFunc { return func(opt *Option) { opt.RedirectURL = url } } func WithCredentials(clientID, clientSecret string) OptionFunc { return func(opt *Option) { opt.ClientID = clientID opt.ClientSecret = clientSecret } } func WithScopes(scopes ...string) OptionFunc { return func(opt *Option) { opt.Scopes = scopes } } func WithAcrValues(acrValues string) OptionFunc { return func(opt *Option) { opt.AcrValues = acrValues } } func WithSkipIssuerCheck(skip bool) OptionFunc { return func(opt *Option) { opt.SkipIssuerCheck = skip } } func NewProvider(ctx context.Context, issuer string, skipIssuerVerification bool) (*oidc.Provider, error) { if skipIssuerVerification { ctx = oidc.InsecureIssuerURLContext(ctx, issuer) } return oidc.NewProvider(ctx, issuer) } func WithProvider(provider *oidc.Provider) OptionFunc { return func(opt *Option) { opt.Provider = provider } } func fromDefault(funcs ...OptionFunc) *Option { opt := &Option{ Scopes: []string{oidc.ScopeOpenID}, } for _, f := range funcs { f(opt) } return opt }