3.9 KiB
Admin Authorization
Purpose
The admin authorization model separates a user's organizational role from the
individual admin capabilities granted to that role. The schema supports multiple
roles even though the initial non-superuser role is only admin.
Core Rules
-
superuseris a hard-coded emergency and governance role.- It does not depend on database permission mappings.
- It bypasses all admin permission checks.
- Creating a replacement superuser or resetting its password remains an installer responsibility.
- Superuser-only account governance actions continue to require the
Superuserauthorization policy.
-
Normal admin access uses Role-Based Access Control.
- A user may have one or more Identity roles through
user_roles. - A role may have one or more admin permissions through
admin_role_permissions. - A user's effective permissions are the union of permissions assigned to all of the user's roles.
- A user may have one or more Identity roles through
-
Roles and role-permission mappings are database data.
- Existing ASP.NET Core Identity
rolesanduser_rolestables remain the source of role membership. admin_permissionsstores the known permission catalog.admin_role_permissionsmaps any Identity role to any admin permission.- Adding roles such as
support,auditor, orsecurity_admindoes not require another schema change.
- Existing ASP.NET Core Identity
-
Permission definitions are owned by application code.
- Permission keys are declared in
AdminPermissions. - Startup and installer seeding synchronize those known definitions into the database.
- The database decides which roles receive known permissions; it must not be used to invent capabilities that have no application implementation.
- Permission keys are declared in
-
Permissions are action-oriented.
- Controllers require a module permission such as
admin.tenants. - Actions also require a capability permission such as
admin.tenants.createoradmin.tenants.delete. - Operations with materially different authorization boundaries must be separate actions and separate permission keys.
- Controllers require a module permission such as
-
Server-side checks are authoritative.
- Admin controllers retain
[Authorize(Policy = "Admin")]as the outer admin boundary. - Controllers and actions use
AdminPermissionAttributefor database-backed permission checks. - Non-admin access to
/admin/*continues to return HTTP 404. - Missing action permissions also return HTTP 404 so inaccessible admin capabilities are not exposed.
- Admin controllers retain
-
Navigation and operation links use the same permission catalog.
- Admin menus reference the same
AdminPermissionsconstants used by the corresponding controller actions. - Buttons and links are hidden when the current user lacks the target action permission.
- UI visibility is only a usability measure; direct requests are always protected by controller/action checks.
- Admin menus reference the same
Initial Mapping
The initial admin role receives every known permission except permissions
marked as superuser-only. This preserves current behavior while allowing the
mapping to be divided among more roles later.
The initial superuser-only permissions are:
admin.accounts.set_adminadmin.accounts.set_disabledadmin.accounts.reset_password
No role or permission maintenance UI is included yet. Until one is introduced, the permission catalog is updated in code and role-permission mappings may be managed through controlled database changes or future installer commands.
Adding an Admin Capability
- Add a constant and definition to
AdminPermissions. - Apply the module permission to the controller.
- Apply the capability permission to every relevant action.
- Use the same action permission for related menu items, links, and buttons.
- Add or update role-permission mappings through the approved seed or administrative workflow.
- Verify direct access, navigation visibility,
admin, andsuperuserbehavior.