@@ -71,6 +71,8 @@ type Options struct {
7171 // potential overrides.
7272 Provider string `flag:"provider" cfg:"provider"`
7373 OIDCIssuerURL string `flag:"oidc-issuer-url" cfg:"oidc_issuer_url"`
74+ SkipOIDCDiscovery bool `flag:"skip-oidc-discovery" cfg:"skip_oidc_discovery"`
75+ OIDCJwksURL string `flag:"oidc-jwks-url" cfg:"oidc_jwks_url"`
7476 LoginURL string `flag:"login-url" cfg:"login_url"`
7577 RedeemURL string `flag:"redeem-url" cfg:"redeem_url"`
7678 ProfileURL string `flag:"profile-url" cfg:"profile_url"`
@@ -121,6 +123,7 @@ func NewOptions() *Options {
121123 PassAuthorization: false,
122124 ApprovalPrompt: "force",
123125 RequestLogging: true,
126+ SkipOIDCDiscovery: false,
124127 RequestLoggingFormat: defaultRequestLoggingFormat,
125128 }
126129}
@@ -161,16 +164,40 @@ func (o *Options) Validate() error {
161164 }
162165
163166 if o.OIDCIssuerURL != "" {
164− // Configure discoverable provider data.
165− provider, err := oidc.NewProvider(context.Background(), o.OIDCIssuerURL)
166− if err != nil {
167− return err
167+
168+ ctx := context.Background()
169+
170+ // Construct a manual IDTokenVerifier from issuer URL & JWKS URI
171+ // instead of metadata discovery if we enable -skip-oidc-discovery.
172+ // In this case we need to make sure the required endpoints for
173+ // the provider are configured.
174+ if o.SkipOIDCDiscovery {
175+ if o.LoginURL == "" {
176+ msgs = append(msgs, "missing setting: login-url")
177+ }
178+ if o.RedeemURL == "" {
179+ msgs = append(msgs, "missing setting: redeem-url")
180+ }
181+ if o.OIDCJwksURL == "" {
182+ msgs = append(msgs, "missing setting: oidc-jwks-url")
183+ }
184+ keySet := oidc.NewRemoteKeySet(ctx, o.OIDCJwksURL)
185+ o.oidcVerifier = oidc.NewVerifier(o.OIDCIssuerURL, keySet, &oidc.Config{
186+ ClientID: o.ClientID,
187+ })
188+ } else {
189+ // Configure discoverable provider data.
190+ provider, err := oidc.NewProvider(ctx, o.OIDCIssuerURL)
191+ if err != nil {
192+ return err
193+ }
194+ o.oidcVerifier = provider.Verifier(&oidc.Config{
195+ ClientID: o.ClientID,
196+ })
197+
198+ o.LoginURL = provider.Endpoint().AuthURL
199+ o.RedeemURL = provider.Endpoint().TokenURL
168200 }
169− o.oidcVerifier = provider.Verifier(&oidc.Config{
170− ClientID: o.ClientID,
171− })
172− o.LoginURL = provider.Endpoint().AuthURL
173− o.RedeemURL = provider.Endpoint().TokenURL
174201 if o.Scope == "" {
175202 o.Scope = "openid email profile"
176203 }