Skip to content

fix(auth): prevent USER_ADMIN from downgrading SUPER_ADMIN users#564

Open
kjken23 wants to merge 1 commit into
iflytek:mainfrom
kjken23:fix/prevent-super-admin-demotion
Open

fix(auth): prevent USER_ADMIN from downgrading SUPER_ADMIN users#564
kjken23 wants to merge 1 commit into
iflytek:mainfrom
kjken23:fix/prevent-super-admin-demotion

Conversation

@kjken23

@kjken23 kjken23 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

  • Tighten admin user role mutation authorization so only SUPER_ADMIN can change role state involving SUPER_ADMIN.
  • Prevent USER_ADMIN from downgrading or replacing an existing SUPER_ADMIN account with USER or another platform role.
  • Add regression coverage to ensure rejected role mutations do not delete or rewrite existing role bindings.

This is needed because the previous backend check only blocked non-SUPER_ADMIN actors from assigning SUPER_ADMIN; it did not protect target users who already had SUPER_ADMIN.

Closes #562

Validation

  • Backend tests passed
  • Frontend typecheck/build passed
  • OpenAPI SDK regenerated or checked when API contracts changed
  • Smoke test run when relevant

Commands run:

make test-backend-app

Result:

Tests run: 574, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

OpenAPI impact:

No API contract changes. No SDK regeneration required.

Frontend impact:

Backend-only authorization behavior change. Frontend typecheck/build not run.

Smoke test:

Not run. This change is covered by backend service regression tests and does not change deployment wiring.

Risk

  • User-facing impact: USER_ADMIN can still manage ordinary users, but attempts to mutate an existing SUPER_ADMIN now return a forbidden error unless the actor is also SUPER_ADMIN.
  • Deployment or migration impact: none. No schema, API contract, generated SDK, or configuration changes.
  • Rollback approach: revert the role mutation guard, localized message keys, and regression test.

Notes

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Prevent USER_ADMIN from downgrading existing SUPER_ADMIN accounts

2 participants