Central UI / /auth/token sign in users whose AD groups map to no role #144

Closed
opened 2026-11-15 20:44:57 -05:00 by dohertj2 · 2 comments
Owner

Body: CentralUI/Auth/AuthEndpoints.cs:59-115 signs in and mints a bearer with an empty role set. With a
domain-wide NAM search base, any AD user reaches Dashboard and Monitoring/Health (bare [Authorize]). The
family standard (scadaproj NAM cutover plan §3.2) refuses login when no role is mapped. Fix login and token,
keep the refresh's end-on-zero, and add tests.

Acceptance: a zero-role user is refused at both endpoints. Plan: docs/plans/2026-11-15-nam-ldap-cutover.md §2A.

Plan: https://gitea.dohertylan.com/dohertj2/scadaproj/src/branch/main/docs/plans/2026-11-15-nam-ldap-cutover.md
Umbrella: scadaproj#6 (NAM AD cutover) · service account: scadaproj#58

**Body:** `CentralUI/Auth/AuthEndpoints.cs:59-115` signs in and mints a bearer with an empty role set. With a domain-wide NAM search base, any AD user reaches `Dashboard` and `Monitoring/Health` (bare `[Authorize]`). The family standard (scadaproj NAM cutover plan §3.2) refuses login when no role is mapped. Fix login and token, keep the refresh's end-on-zero, and add tests. **Acceptance:** a zero-role user is refused at both endpoints. Plan: `docs/plans/2026-11-15-nam-ldap-cutover.md` §2A. Plan: https://gitea.dohertylan.com/dohertj2/scadaproj/src/branch/main/docs/plans/2026-11-15-nam-ldap-cutover.md Umbrella: scadaproj#6 (NAM AD cutover) · service account: scadaproj#58
dohertj2 added the type:bugpriority:p1cross-repo labels 2026-11-15 20:44:57 -05:00
Author
Owner

Fixed and merged to main in d48e1667 (branch fix/144-refuse-zero-role-login: 5a642d1c, 2d8d5a3d, 764e75c3). Not deployed. Deployment is on hold by owner decision and is tracked with the cutover in scadaproj#6.

What changed:

  • /auth/login and /auth/token refuse a sign-in whose groups map to zero roles, and also refuse when the mapper throws. The client gets exactly what a bad password gets: the same redirect message or the same 401 AUTH_FAILED, with no cookie or token.
  • Each refusal is logged at Warning with the endpoint, the user and the reason.
  • A refusal counts as a throttle failure, so the lockout doesn't reveal valid-password, no-role accounts. One consequence: while the config DB is down, retrying a correct password can lock the user out for the window.
  • CookieSessionValidator now ends a session whose refresh maps to zero roles, for both the DB re-map and the directory re-query. Before this, a user who stayed in only unmapped groups kept a role-less session that could read / and /monitoring/health.
  • There are no login audit events today, so the log line is the only record of a refusal.
  • Component-Security.md has a new "No role, no login" section, and Component-CentralUI.md and CLAUDE.md were updated.

Tests:

  • The solution builds.
  • CentralUI.Tests 1608, Security.Tests 234 and ManagementService.Tests 778 all passed.
  • IntegrationTests run against live GLAuth: AuthFlowTests 7/7 passed. Two tests that relied on zero-role sign-in were fixed.
  • The new tests fail against the old code.

Known gap, not fixed here: the management API's HTTP Basic login (ManagementAuthenticator) still admits a zero-role user to read-only queries. That needs a follow-up issue before the cutover (§7.4).

Fixed and merged to `main` in `d48e1667` (branch `fix/144-refuse-zero-role-login`: `5a642d1c`, `2d8d5a3d`, `764e75c3`). **Not deployed.** Deployment is on hold by owner decision and is tracked with the cutover in scadaproj#6. **What changed:** - `/auth/login` and `/auth/token` refuse a sign-in whose groups map to zero roles, and also refuse when the mapper throws. The client gets exactly what a bad password gets: the same redirect message or the same 401 `AUTH_FAILED`, with no cookie or token. - Each refusal is logged at Warning with the endpoint, the user and the reason. - A refusal counts as a throttle failure, so the lockout doesn't reveal valid-password, no-role accounts. One consequence: while the config DB is down, retrying a correct password can lock the user out for the window. - `CookieSessionValidator` now ends a session whose refresh maps to zero roles, for both the DB re-map and the directory re-query. Before this, a user who stayed in only unmapped groups kept a role-less session that could read `/` and `/monitoring/health`. - There are no login audit events today, so the log line is the only record of a refusal. - `Component-Security.md` has a new "No role, no login" section, and `Component-CentralUI.md` and `CLAUDE.md` were updated. **Tests:** - The solution builds. - CentralUI.Tests 1608, Security.Tests 234 and ManagementService.Tests 778 all passed. - IntegrationTests run against live GLAuth: AuthFlowTests 7/7 passed. Two tests that relied on zero-role sign-in were fixed. - The new tests fail against the old code. **Known gap, not fixed here:** the management API's HTTP Basic login (`ManagementAuthenticator`) still admits a zero-role user to read-only queries. That needs a follow-up issue before the cutover (§7.4).
Author
Owner

Follow-up filed: ScadaBridge#145, the management API HTTP Basic / Bearer path still admits zero-role users. Fix it before the ScadaBridge cutover step (plan §7.4).

Follow-up filed: ScadaBridge#145, the management API HTTP Basic / Bearer path still admits zero-role users. Fix it before the ScadaBridge cutover step (plan §7.4).
Sign in to join this conversation.