Skip to content

Commit 961a9a9

Browse files
committed
feat: implement disabling oidc issuer checks
1 parent a862bf1 commit 961a9a9

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

cli/server.go

+8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ func createOIDCConfig(ctx context.Context, vals *codersdk.DeploymentValues) (*co
114114
return nil, xerrors.Errorf("OIDC issuer URL must be set!")
115115
}
116116

117+
// Skipping issuer checks is not recommended.
118+
if vals.OIDC.SkipIssuerChecks {
119+
ctx = oidc.InsecureIssuerURLContext(ctx, vals.OIDC.IssuerURL.String())
120+
}
121+
117122
oidcProvider, err := oidc.NewProvider(
118123
ctx, vals.OIDC.IssuerURL.String(),
119124
)
@@ -167,6 +172,9 @@ func createOIDCConfig(ctx context.Context, vals *codersdk.DeploymentValues) (*co
167172
Provider: oidcProvider,
168173
Verifier: oidcProvider.Verifier(&oidc.Config{
169174
ClientID: vals.OIDC.ClientID.String(),
175+
// Enabling this skips checking the "iss" claim in the token
176+
// matches the issuer URL. This is not recommended.
177+
SkipIssuerCheck: vals.OIDC.SkipIssuerChecks.Value(),
170178
}),
171179
EmailDomain: vals.OIDC.EmailDomain,
172180
AllowSignups: vals.OIDC.AllowSignups.Value(),

coderd/coderdtest/oidctest/idp_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func TestIDPIssuerMismatch(t *testing.T) {
102102
ctx = oidc.ClientContext(ctx, cli)
103103

104104
// Allow the issuer mismatch
105-
ctx = oidc.InsecureIssuerURLContext(ctx, "this field does not matter")
106-
p, err := oidc.NewProvider(ctx, "https://proxy.com")
105+
verifierContext := oidc.InsecureIssuerURLContext(ctx, "this field does not matter")
106+
p, err := oidc.NewProvider(verifierContext, "https://proxy.com")
107107
require.NoError(t, err, "failed to create OIDC provider")
108108

109109
oauthConfig := fake.OauthConfig(t, nil)

codersdk/deployment.go

+11
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ type OIDCConfig struct {
353353
SignInText serpent.String `json:"sign_in_text" typescript:",notnull"`
354354
IconURL serpent.URL `json:"icon_url" typescript:",notnull"`
355355
SignupsDisabledText serpent.String `json:"signups_disabled_text" typescript:",notnull"`
356+
SkipIssuerChecks serpent.Bool `json:"skip_issuer_checks" typescript:",notnull"`
356357
}
357358

358359
type TelemetryConfig struct {
@@ -1474,6 +1475,16 @@ when required by your organization's security policy.`,
14741475
Group: &deploymentGroupOIDC,
14751476
YAML: "signupsDisabledText",
14761477
},
1478+
{
1479+
Name: "Skip OIDC issuer checks (not recommended)",
1480+
Description: "OIDC issuer urls must match in the request, the id_token 'iss' claim, and in the well-known configuration. " +
1481+
"This flag disables that requirement, and can lead to an insecure OIDC configuration. It is not recommended to use this flag.",
1482+
Flag: "oidc-skip-issuer-checks",
1483+
Env: "CODER_OIDC_SKIP_ISSUER_CHECKS",
1484+
Value: &c.OIDC.SkipIssuerChecks,
1485+
Group: &deploymentGroupOIDC,
1486+
YAML: "skipIssuerChecks",
1487+
},
14771488
// Telemetry settings
14781489
{
14791490
Name: "Telemetry Enable",

0 commit comments

Comments
 (0)