Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.ManagementService.Tests
Joseph Doherty 1d2170a152 fix(management): refuse zero-role principals on the management/CLI surfaces (#145)
ManagementAuthenticator — the only identity source for POST /management, the
audit REST endpoints and the debug-stream hub — now enforces "no role, no
login" the way #144 does for /auth/login and /auth/token:

- HTTP Basic: a bind whose groups map to zero roles, or whose role mapping
  throws, answers the bad-password 401 AUTH_FAILED body and counts as a
  LoginThrottle failure. RecordSuccess moved after the mapping, so a refusal
  no longer clears earlier failures. Request cancellation still propagates.
- Bearer: a token with no role claim (minted before #144 shipped) gets the
  invalid-token 401; no throttle, as for every bearer failure.
- Each refusal is logged at Warning (category ManagementAuthenticator) with
  the request path, the username and the reason.

Before this, a zero-role Basic caller reached every command that
ManagementActor.GetRequiredRoles opens to any authenticated user.
DisableLogin is unchanged.

Tests: ManagementZeroRoleRefusalTests — zero roles / mapper throws / one role
over Basic and Bearer for /management (ListSites), /api/audit/query and the
debug-stream hub; every null-role command is unreachable by a zero-role
principal; throttle accounting. 47 of the 58 fail against the old
authenticator (the 11 that pass are the one-role/bypass regression guards).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:45:51 -05:00
..