Skip to content

Commit 5cdf612

Browse files
committed
feat: custom error message on signups disabled page
1 parent a34cada commit 5cdf612

File tree

9 files changed

+43
-2
lines changed

9 files changed

+43
-2
lines changed

cli/server.go

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ func createOIDCConfig(ctx context.Context, vals *codersdk.DeploymentValues) (*co
179179
UserRoleMapping: vals.OIDC.UserRoleMapping.Value,
180180
UserRolesDefault: vals.OIDC.UserRolesDefault.GetSlice(),
181181
SignInText: vals.OIDC.SignInText.String(),
182+
SignupsDisabledText: vals.OIDC.SignupsDisabledText.String(),
182183
IconURL: vals.OIDC.IconURL.String(),
183184
IgnoreEmailVerified: vals.OIDC.IgnoreEmailVerified.Value(),
184185
}, nil

coderd/apidoc/docs.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/userauth.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ type OIDCConfig struct {
740740
SignInText string
741741
// IconURL points to the URL of an icon to display on the OIDC login button
742742
IconURL string
743+
// SignupsDisabledText is the text do display on the static error page.
744+
SignupsDisabledText string
743745
}
744746

745747
func (cfg OIDCConfig) RoleSyncEnabled() bool {
@@ -1313,9 +1315,15 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13131315
}
13141316

13151317
if user.ID == uuid.Nil && !params.AllowSignups {
1318+
signupsDisabledText := api.OIDCConfig.SignupsDisabledText
1319+
if signupsDisabledText == "" {
1320+
signupsDisabledText = "Please contact your Coder administrator to request access."
1321+
}
13161322
return httpError{
1317-
code: http.StatusForbidden,
1318-
msg: fmt.Sprintf("Signups are not allowed for login type %q", params.LoginType),
1323+
code: http.StatusBadRequest,
1324+
msg: "Signups are disabled",
1325+
detail: signupsDisabledText,
1326+
renderStaticPage: true,
13191327
}
13201328
}
13211329

codersdk/deployment.go

+10
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ type OIDCConfig struct {
303303
UserRolesDefault clibase.StringArray `json:"user_roles_default" typescript:",notnull"`
304304
SignInText clibase.String `json:"sign_in_text" typescript:",notnull"`
305305
IconURL clibase.URL `json:"icon_url" typescript:",notnull"`
306+
SignupsDisabledText clibase.String `json:"signups_disabled_text" typescript:",notnull"`
306307
}
307308

308309
type TelemetryConfig struct {
@@ -1266,6 +1267,15 @@ when required by your organization's security policy.`,
12661267
Group: &deploymentGroupOIDC,
12671268
YAML: "iconURL",
12681269
},
1270+
{
1271+
Name: "Signups disabled text",
1272+
Description: "The custom text to show on the error page informing about disabled OIDC signups.",
1273+
Flag: "oidc-signups-disabled-text",
1274+
Env: "CODER_OIDC_SIGNUPS_DISABLED_TEXT",
1275+
Value: &c.OIDC.SignupsDisabledText,
1276+
Group: &deploymentGroupOIDC,
1277+
YAML: "signupsDisabledText",
1278+
},
12691279
// Telemetry settings
12701280
{
12711281
Name: "Telemetry Enable",

docs/api/general.md

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/cli/server.md

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)