Management API HTTP Basic (CLI) still signs in users whose AD groups map to no role #145
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up from #144, part of the NAM AD LDAP cutover (scadaproj#6, plan
scadaproj/docs/plans/2026-11-15-nam-ldap-cutover.md§2A / §3 "no role, no login").Problem
#144 (merged in
d48e1667) made/auth/login,/auth/tokenand the cookie-session refresh refuse a user whose AD groups map to zero ScadaBridge roles. The management surfaces were left out. Their HTTP Basic login still lets that user in.ManagementAuthenticator.AuthenticateAsync(src/ZB.MOM.WW.ScadaBridge.ManagementService/ManagementAuthenticator.cs, around lines 149–160) binds against LDAP, callsRoleMapper.MapGroupsToRolesAsync, and builds anAuthenticatedUsereven when the role set is empty. Per-command authorization inManagementActor.HandleEnvelope/GetRequiredRolesdenies role-gated commands. However, every command whereGetRequiredRolesreturnsnull(open to any authenticated user) still answers a zero-role caller.The callers are
ManagementEndpoints(/management, used by the CLI),AuditEndpointsandDebugStreamHub.Why it matters
Once NAM AD is on, any NAM user with a valid password can query ScadaBridge's read-only management surface over Basic. This includes anyone in only unrelated
UG_WW_*/ Citrix / plant groups, or in no family group at all. That violates the family standard (no role, no login) and undercuts #144.Fix
AUTH_FAILEDbody as a bad password, and count it as aLoginThrottlefailure (as in #144). If the mapper throws, refuse in the same way, with the same status policy #144 chose.AuthenticateBearer): refuse a token whose role claim set is empty./auth/tokencan no longer mint one, but tokens minted before the deploy can still exist until they expire.DebugStreamHubandAuditEndpointsgo through the same refusal, so none of them builds its ownAuthenticatedUserwithout it.DisableLogindev bypass is unchanged, since it usesRoles.All.docs/requirements/Component-Security.mdto cover the management/CLI surfaces.Acceptance
/managementread-only (GetRequiredRoles == null) command;DebugStreamHubconnect.null-role command is reachable by a zero-role principal.Fixed and merged to
mainin2e0ce81e(branchfix/145-management-zero-role:1d2170a1,a5243b1e). Not deployed. Deployment is on hold by owner decision and is tracked with the cutover in scadaproj#6.Basic: zero roles, or a throwing mapper, gets the bad-password 401
{ error: "Invalid username or password.", code: "AUTH_FAILED" }. This covers/management,/api/audit/*and theDebugStreamHubconnect, which aborts the connection. Each refusal counts as aLoginThrottlefailure and logs a Warning naming the path, the user and the reason.Throttle ordering:
RecordSuccessnow runs only after the role mapping succeeds, so a refusal no longer clears earlier failures.Bearer: a token with no role claim gets the existing invalid-token 401. Blank role values are ignored. As with every other bearer failure, it does not count toward the throttle.
DisableLogin: unchanged, and a test pins it.Docs: Component-Security, Component-CLI, Component-ManagementService and CLAUDE.md are updated.
Tests:
GetRequiredRoles == nullcommand, over Basic and Bearer, as a zero-role principal and expects 401.Other paths checked; none admit a zero-role user:
DeploymentConfigEndpoints(per-deployment token);Note: a CLI run that makes several Basic calls as a zero-role user adds one throttle failure per call.