Skip to content

Replace is_superuser with role-based access control - #2531

Closed
Cherinho wants to merge 2 commits into
fastapi:masterfrom
Cherinho:test-task
Closed

Cherinho wants to merge 2 commits into
fastapi:masterfrom
Cherinho:test-task

Conversation

@Cherinho

Copy link
Copy Markdown

Introduce a UserRole enum (admin, manager, member) to replace the boolean is_superuser flag across the backend and frontend.

Backend changes:

  • Add UserRole StrEnum and migrate User models to use role field
  • Create Alembic migration to add role column and drop is_superuser
  • Add legacy is_superuser compatibility via model validators
  • Rename get_current_active_superuser to get_current_active_admin
  • Add get_current_manager_or_admin dependency for shared admin/manager access
  • Add new /metrics endpoint accessible to admin and manager roles
  • Update item routes to check role instead of is_superuser

Frontend changes:

  • Replace superuser checkbox with role dropdown in AddUser and EditUser forms
  • Gate admin-only actions (user deletion, AddUser button) by role
  • Add Metrics page showing user and item counts
  • Update sidebar to show Users and Metrics links for admin/manager roles
  • Add token validation on layout route to redirect on auth errors
  • Regenerate API client types with new role and metrics schemas

Cherinho and others added 2 commits November 18, 2026 20:04
Introduce a UserRole enum (admin, manager, member) to replace the boolean
is_superuser flag across the backend and frontend.

Backend changes:
- Add UserRole StrEnum and migrate User models to use role field
- Create Alembic migration to add role column and drop is_superuser
- Add legacy is_superuser compatibility via model validators
- Rename get_current_active_superuser to get_current_active_admin
- Add get_current_manager_or_admin dependency for shared admin/manager access
- Add new /metrics endpoint accessible to admin and manager roles
- Update item routes to check role instead of is_superuser

Frontend changes:
- Replace superuser checkbox with role dropdown in AddUser and EditUser forms
- Gate admin-only actions (user deletion, AddUser button) by role
- Add Metrics page showing user and item counts
- Update sidebar to show Users and Metrics links for admin/manager roles
- Add token validation on layout route to redirect on auth errors
- Regenerate API client types with new role and metrics schemas
@Cherinho Cherinho closed this Nov 18, 2026
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.

1 participant