AdminUI LDAP: drops FallbackServers/BindMode/…, signs in users with no mapped role, and the library logs nothing #913

Closed
opened 2026-11-15 20:44:56 -05:00 by dohertj2 · 1 comment
Owner

Body:

  1. LdapOptions.ToLibraryOptions() (Security/Ldap/LdapOptions.cs:111) drops FallbackServers, BindMode,
    UserBindTemplate and AcceptDomainQualifiedNames, so there is no AD DC failover.
  2. AuthEndpoints.cs:124-158 signs in with an empty role set, including when the mapper throws, and
    AuthenticatedRead admits any authenticated user. Once the search base is a whole AD domain, any directory
    user gets AdminUI read access and a token. The fix refuses empty roles at /auth/login and /auth/token,
    and refuses when the mapper throws. This reverses Login_when_role_mapper_throws_signs_in_with_no_role_claims.
  3. OtOpcUaLdapAuthService.cs:48 passes no logger to the library, so failover and stage logs are missing.
    Inject ILogger<LdapAuthService>.
  4. Validate the new options in OtOpcUa's own validator: the fallback parse rule and the BindMode/UserBindTemplate
    rules only. Not ServiceAccountDn, because DEV boots on code defaults with an empty DN.
  5. A two-way reflection completeness test, a binding test, docs, and fixes to the stale comments.

Acceptance: failover on the redundant GLAuth pair, a zero-role user refused (cookie + token), and a
DEV-shaped config boots. Plan: scadaproj/docs/plans/2026-11-15-nam-ldap-cutover.md §2.

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:** 1. `LdapOptions.ToLibraryOptions()` (`Security/Ldap/LdapOptions.cs:111`) drops `FallbackServers`, `BindMode`, `UserBindTemplate` and `AcceptDomainQualifiedNames`, so there is no AD DC failover. 2. `AuthEndpoints.cs:124-158` signs in with an empty role set, including when the mapper throws, and `AuthenticatedRead` admits any authenticated user. Once the search base is a whole AD domain, any directory user gets AdminUI read access and a token. The fix refuses empty roles at `/auth/login` and `/auth/token`, and refuses when the mapper throws. This reverses `Login_when_role_mapper_throws_signs_in_with_no_role_claims`. 3. `OtOpcUaLdapAuthService.cs:48` passes no logger to the library, so failover and stage logs are missing. Inject `ILogger<LdapAuthService>`. 4. Validate the new options in OtOpcUa's own validator: the fallback parse rule and the BindMode/UserBindTemplate rules only. **Not** `ServiceAccountDn`, because DEV boots on code defaults with an empty DN. 5. A two-way reflection completeness test, a binding test, docs, and fixes to the stale comments. **Acceptance:** failover on the redundant GLAuth pair, a zero-role user refused (cookie + token), and a DEV-shaped config boots. Plan: `scadaproj/docs/plans/2026-11-15-nam-ldap-cutover.md` §2. 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:56 -05:00
Author
Owner

Fixed and merged to master in cdf433a35 (branch fix/913-adminui-ldap-options: c996b462c, 46d9a19bc, 19a445bb6). Not deployed. Deployment is on hold by owner decision and is tracked with the cutover in scadaproj#6.

What changed:

  • ToLibraryOptions() now passes FallbackServers, BindMode, UserBindTemplate and AcceptDomainQualifiedNames through to the library. A two-way reflection test fails on any library property that is not mapped or explicitly listed as unmapped. Only ServerCertificateValidationCallback is unmapped, because it can't be set from config.
  • No role, no login: a sign-in whose groups map to zero roles is refused like a bad password, with no cookie and no token. The refusal is logged with the groups. /auth/token returns 401 for a cookie session that has no role.
  • If the mapper throws, sign-in is refused and the exception is logged. This returns 503 to JSON callers, matching the existing response when LDAP itself throws; browser users see "Sign-in is temporarily unavailable".
  • The library's ILogger<LdapAuthService> is now injected.
  • Startup validation gained two rules: each fallback entry must be host or host:port, and BindMode=User needs a template containing {0} exactly once. ServiceAccountDn is not required, and a test confirms the DEV-shaped config still boots.
  • docs/security.md and docs/Configuration.md were updated.

Tests:

  • The solution builds with 0 warnings and 0 errors.
  • Security.Tests: 115/115 passed.
  • Host.IntegrationTests: 370 passed, 2 skipped (Modbus fixture), 0 failed.
  • RoleAuthorityGuard: 5/5 passed.
  • The new guard tests were checked to fail when the code is deliberately broken.

Notes for rollout:

  • Role-less cookies issued before the deploy stay valid until they expire, because AuthenticatedRead still admits a signed-in user with no roles. Restart the service or accept that window (plan §7.5).
  • Acceptance check A1 (live failover on the redundant GLAuth pair) has not been run yet.
  • OtOpcUa still pins Auth 0.4.1, so the fallback-entry rule was ported from that release.
Fixed and merged to `master` in `cdf433a35` (branch `fix/913-adminui-ldap-options`: `c996b462c`, `46d9a19bc`, `19a445bb6`). **Not deployed.** Deployment is on hold by owner decision and is tracked with the cutover in scadaproj#6. **What changed:** - `ToLibraryOptions()` now passes `FallbackServers`, `BindMode`, `UserBindTemplate` and `AcceptDomainQualifiedNames` through to the library. A two-way reflection test fails on any library property that is not mapped or explicitly listed as unmapped. Only `ServerCertificateValidationCallback` is unmapped, because it can't be set from config. - No role, no login: a sign-in whose groups map to zero roles is refused like a bad password, with no cookie and no token. The refusal is logged with the groups. `/auth/token` returns 401 for a cookie session that has no role. - If the mapper throws, sign-in is refused and the exception is logged. This returns **503** to JSON callers, matching the existing response when LDAP itself throws; browser users see "Sign-in is temporarily unavailable". - The library's `ILogger<LdapAuthService>` is now injected. - Startup validation gained two rules: each fallback entry must be `host` or `host:port`, and `BindMode=User` needs a template containing `{0}` exactly once. `ServiceAccountDn` is **not** required, and a test confirms the DEV-shaped config still boots. - `docs/security.md` and `docs/Configuration.md` were updated. **Tests:** - The solution builds with 0 warnings and 0 errors. - Security.Tests: 115/115 passed. - Host.IntegrationTests: 370 passed, 2 skipped (Modbus fixture), 0 failed. - RoleAuthorityGuard: 5/5 passed. - The new guard tests were checked to fail when the code is deliberately broken. **Notes for rollout:** - Role-less cookies issued before the deploy stay valid until they expire, because `AuthenticatedRead` still admits a signed-in user with no roles. Restart the service or accept that window (plan §7.5). - Acceptance check A1 (live failover on the redundant GLAuth pair) has not been run yet. - OtOpcUa still pins Auth 0.4.1, so the fallback-entry rule was ported from that release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#913