Admin Roles & Permissions System
Overview
This document describes the role hierarchy and permission system for managing site operations, employees, and access control.
Role Hierarchy
Owner > Admin > Moderator > Standard
Role Definitions
-
Owner (You - Site Owner)
- Full access to everything
- Can manage system settings
- Can manage employees and permissions
- Cannot be demoted or banned
- Bypasses all permission checks
-
Admin (Your Employees)
- Can manage users, content, tournaments, events
- Can ban users
- Can approve/reject tournaments and events
- Can manage regulations and reference data
- Cannot modify system settings
- Cannot manage other admins' permissions
- Has permissions by default (unless explicitly denied)
-
Moderator (Content Moderators)
- Can moderate content (posts, comments)
- Can review AI-flagged content
- Can view audit logs (if granted permission)
- Cannot ban users
- Cannot manage users
- Cannot approve tournaments
- Needs explicit permissions granted
-
Standard (Regular Users)
- No admin access
- Regular user features only
Permission System
Granular Permissions
Instead of just roles, you can grant specific permissions to employees:
User Management:
Users.View- View user listUsers.Edit- Edit user detailsUsers.Ban- Ban usersUsers.Unban- Unban usersUsers.Delete- Delete usersUsers.ChangeRole- Change user roles
Content Moderation:
Content.Moderate- Moderate contentContent.Delete- Delete contentContent.Approve- Approve content
Tournament Management:
Tournaments.View- View tournamentsTournaments.Approve- Approve tournamentsTournaments.Reject- Reject tournamentsTournaments.Suspend- Suspend tournaments
Organizer Management:
Organizers.View- View organizersOrganizers.Verify- Verify organizersOrganizers.Suspend- Suspend organizers
Event Management:
Events.View- View eventsEvents.Approve- Approve eventsEvents.Reject- Reject events
Regulations:
Regulations.View- View regulationsRegulations.Edit- Edit regulations
Reference Data:
Brands.Manage- Manage brandsSpecies.Manage- Manage fish speciesLookups.Manage- Manage lookup tables
System Settings (Owner Only):
Settings.View- View system settingsSettings.Modify- Modify system settingsSettings.Delete- Delete system settings
Announcements:
Announcements.Create- Create announcementsAnnouncements.Edit- Edit announcementsAnnouncements.Delete- Delete announcements
Audit Logs:
AuditLogs.View- View audit logsAuditLogs.Export- Export audit logs
Employee Management (Owner Only):
Employees.Manage- Manage employeesPermissions.Manage- Manage permissions
New Admin Features
1. AdminSystemSettingsController (/api/admin/system-settings)
Owner Only - Manage site-wide configuration
Features:
- Create/update/delete system settings
- Hide sensitive values (API keys, passwords)
- Track who changed what
- Categorize settings (General, Features, Integrations, Email)
- Mark settings that require app restart
Example Settings:
SiteName- Site nameMaintenanceMode- Enable/disable maintenance modeMaxFileUploadSize- Maximum file upload sizeStripeApiKey- Stripe API key (sensitive)EmailSmtpHost- Email server settingsFeatureFlags- JSON for feature flags
2. AdminEmployeeController (/api/admin/employees)
Owner Only - Manage employees and their permissions
Features:
- View all admin/moderator employees
- Grant/revoke specific permissions
- Change employee roles
- View permission history
- Set restrictions (e.g., max ban duration)
Use Cases:
- Hire a content moderator → Grant
Content.Moderatepermission - Hire a tournament manager → Grant
Tournaments.Approvepermission - Restrict an admin → Revoke
Users.Deletepermission - Promote moderator to admin → Change role
3. AdminAuditLogController (/api/admin/audit-logs)
Requires Permission - View audit logs
Features:
- Track all admin actions
- See who did what and when
- Filter by action, user, date range
- View statistics (most active admins, common actions)
- IP address and user agent tracking
Tracked Actions:
- User bans/unbans
- Tournament approvals/rejections
- Setting changes
- Permission grants/revocations
- Content moderation actions
4. AdminAnnouncementController (/api/admin/announcements)
Requires Permission - Create site-wide announcements
Features:
- Create banners/notifications
- Schedule announcements (start/end dates)
- Target specific user tiers
- Dismissible or persistent
- Priority levels (Low, Normal, High, Critical)
- Types (Info, Success, Warning, Error)
Use Cases:
- "Site maintenance scheduled for Sunday"
- "New feature: Tournament registration!"
- "Important: Terms of Service updated"
Authorization Attributes
[AdminOnly]
- Allows Admin and Owner
- Use for general admin endpoints
[OwnerOnly]
- Only allows Owner
- Use for system settings, employee management
[RequirePermission("Permission.Name")]
- Checks specific permission
- Owner bypasses check
- Admin has permission by default (unless denied)
- Moderator needs explicit grant
Example:
[RequirePermission(Permissions.UsersBan)]
public async Task<ActionResult> BanUser(...)
{
// Only users with Users.Ban permission can access
}
Employee Management Workflow
Hiring a Content Moderator
- Create user account (or use existing)
- Change role to Moderator:
PUT /api/admin/employees/{userId}/role
{ "role": "Moderator" } - Grant permissions:
POST /api/admin/employees/{userId}/permissions
{
"permission": "Content.Moderate",
"isGranted": true
}
Hiring a Tournament Manager
- Create user account
- Change role to Admin:
PUT /api/admin/employees/{userId}/role
{ "role": "Admin" } - Grant tournament permissions:
POST /api/admin/employees/{userId}/permissions
{
"permission": "Tournaments.Approve",
"isGranted": true
} - Optionally deny other permissions:
POST /api/admin/employees/{userId}/permissions
{
"permission": "Users.Delete",
"isGranted": false // Explicitly deny
}
Security Features
Audit Logging
- All admin actions are logged
- Tracks: who, what, when, why, IP address
- Cannot be deleted (compliance)
- Exportable for compliance reports
Permission Restrictions
- Can set restrictions on permissions (JSON)
- Example:
{"maxBanDurationDays": 7}forUsers.Ban - Prevents abuse of permissions
Role Protection
- Cannot remove last admin
- Cannot change owner role
- Cannot ban owner
Best Practices
-
Start with Roles, Add Permissions as Needed
- Most admins can use default Admin role
- Only grant specific permissions when restrictions needed
-
Use Moderator Role for Content-Only Access
- Moderators can't ban users or manage system
- Perfect for community moderators
-
Audit Regularly
- Review audit logs weekly
- Check for unusual activity
- Monitor permission grants
-
Document Permission Changes
- Use
Reasonfield when granting/revoking - Helps track why permissions were changed
- Use
-
Use System Settings for Configuration
- Don't hardcode values
- Easy to change without deployment
- Track changes in audit log
Migration Path
When you're ready to add employees:
-
Set yourself as Owner:
UPDATE "Users" SET "Role" = 5 WHERE "Email" = 'your@email.com'; -
Create employee accounts (or promote existing users)
-
Assign roles via
AdminEmployeeController -
Grant permissions as needed
-
Monitor via audit logs
Summary
You now have:
- ✅ Role hierarchy (Owner > Admin > Moderator)
- ✅ Granular permissions for fine-grained control
- ✅ Employee management for assigning roles/permissions
- ✅ Audit logging for compliance and security
- ✅ System settings for site configuration
- ✅ Announcements for site-wide messaging
This gives you full control over your site and employees, with the flexibility to grant exactly the permissions each employee needs.