feat(auth): translate Bunyip bunyip_role claim to mokosh role (PMS-172) #142
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-172-bunyip-role-translation"
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?
What
Implements PMS-172: on the Bunyip Resource-Server auth path, mokosh now derives the request role by translating Bunyip's
bunyip_roleclaim instead of blindly using the local JIT-createdusers.role(which defaults totechnician). This is why a Bunyip admin showed up astechnicianin mokosh and the PMS-155 E2E suite 403'd.Model (confirmed with the team)
Bunyip is the SSO/identity manager and governs only the TOP role; everything below it stays mokosh-internal:
bunyip_role = "admin"-> mokoshsuper_admin(authoritative).bunyip_role = "subscriber"-> the user's locally-assigned mokosh role (admin/manager/finance/technician/...), EXCEPTsuper_adminis Bunyip-exclusive, so a stale/localsuper_adminis clamped toadmin.subscriber(never elevates, still clamps a stalesuper_admin).None) -> keep the local role unchanged.Bunyip's role vocabulary is only
{subscriber, admin}(bunyip/crates/bunyip-domain/src/models/user.rs); mokosh owns the translation so Bunyip never has to know mokosh's taxonomy.Changes
oidc_rs::AtClaimsgainsbunyip_role: Option<String>(#[serde(default)], so older tokens ->None).effective_role_from_bunyip(bunyip_role, local) -> UserRoleinmiddleware.rs(pure, unit-tested).ensure_user_from_bunyipcomputes the effective role and reconciles the shadow row via the newAuthService::set_user_role(plain UPDATE, no audit, fires only when the role changed); the effective role flows intoAuthState.Back-compat / scope
With no claim the effective role equals the local role, so the legacy HS256 cookie path and standalone/single-tenant deployments are completely untouched. The mokosh-auth
at+jwtpath (parse_mokosh_role) is deliberately not reused or changed.Depends on
bunyip_rolein the at+jwt). This change is inert until that lands - safe to merge first.Tests
cargo check --all-targets,clippy --all-targets, andfmt --checkall clean.e2e/README.mddoc update tracked on PMS-172 once the claim is live.🤖 Generated with Claude Code