Commit e94de0b
fix(coderd): render HTML error page for OIDC email validation failures (#23059)
## Summary
When the email address returned from an OIDC provider doesn't match the
configured allowed domain list (or isn't verified), users previously saw
raw JSON dumped directly in the browser — an ugly and confusing
experience during a browser-redirect flow.
This PR replaces those JSON responses with the same styled static HTML
error page already used for group allow-list errors, signups-disabled,
and wrong-login-type errors.
## Changes
### `coderd/userauth.go`
Replaced 3 `httpapi.Write` calls in `userOIDC` with
`site.RenderStaticErrorPage`:
| Error case | Title shown |
|---|---|
| Email domain not in allowed list | "Unauthorized email" |
| Malformed email (no `@`) with domain restrictions | "Unauthorized
email" |
| `email_verified` is `false` | "Email not verified" |
All render HTTP 403 with `HideStatus: true` and a "Back to login" action
button.
### `coderd/userauth_test.go`
- Updated `AssertResponse` callbacks on existing table-driven tests
(`EmailNotVerified`, `NotInRequiredEmailDomain`,
`EmailDomainForbiddenWithLeadingAt`) to verify HTML Content-Type and
page content.
- Extended `TestOIDCDomainErrorMessage` to additionally assert HTML
rendering.
- Added new `TestOIDCErrorPageRendering` with 3 subtests covering all
error scenarios, verifying: HTML doctype, expected title/description,
"Back to login" link, and absence of JSON markers.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent fa86936 commit e94de0b
2 files changed
Lines changed: 84 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
1343 | 1344 | | |
1344 | 1345 | | |
1345 | 1346 | | |
1346 | | - | |
1347 | | - | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1348 | 1358 | | |
1349 | 1359 | | |
1350 | 1360 | | |
1351 | | - | |
| 1361 | + | |
1352 | 1362 | | |
1353 | 1363 | | |
1354 | 1364 | | |
| |||
1370 | 1380 | | |
1371 | 1381 | | |
1372 | 1382 | | |
1373 | | - | |
1374 | | - | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1375 | 1394 | | |
1376 | 1395 | | |
1377 | 1396 | | |
| |||
1385 | 1404 | | |
1386 | 1405 | | |
1387 | 1406 | | |
1388 | | - | |
1389 | | - | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
1390 | 1418 | | |
1391 | 1419 | | |
1392 | 1420 | | |
| |||
1406 | 1434 | | |
1407 | 1435 | | |
1408 | 1436 | | |
1409 | | - | |
1410 | 1437 | | |
1411 | 1438 | | |
1412 | 1439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1107 | 1107 | | |
1108 | 1108 | | |
1109 | 1109 | | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
1110 | 1122 | | |
1111 | 1123 | | |
1112 | | - | |
1113 | | - | |
| 1124 | + | |
1114 | 1125 | | |
1115 | 1126 | | |
1116 | 1127 | | |
| |||
1144 | 1155 | | |
1145 | 1156 | | |
1146 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
1147 | 1170 | | |
1148 | 1171 | | |
1149 | 1172 | | |
| |||
1170 | 1193 | | |
1171 | 1194 | | |
1172 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1173 | 1208 | | |
1174 | 1209 | | |
1175 | 1210 | | |
| |||
2062 | 2097 | | |
2063 | 2098 | | |
2064 | 2099 | | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
2065 | 2106 | | |
2066 | 2107 | | |
2067 | 2108 | | |
| |||
2091 | 2132 | | |
2092 | 2133 | | |
2093 | 2134 | | |
2094 | | - | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
2095 | 2141 | | |
2096 | 2142 | | |
2097 | 2143 | | |
| |||
0 commit comments