role column of public.users. The API trusts the Supabase access token for who you are and the database for what you may do.
Sign-in
Clients send the session’s access token on every API call:
Token validation
Configured inProgram.cs with AddJwtBearer:
Roles
- Allowed roles are
adminanduser(AdminFieldRules.AllowedRoles). - New users are created with
userbyUserSyncServicethe first time they create a thread, run a battle or chat. An existing role is never overwritten by that sync. - The
AdminOnlypolicy isRequireRole("admin"). All nine admin controllers use it. - Because the role is read on each request, promoting or demoting someone takes effect on their next call; no new token is needed.
Endpoint access
The admin gate
The admin panel doesn’t decide who is an admin; the API does.1
Sign in
Email and password against Supabase Auth.
2
Ask the API
GET /api/admin/dashboard/health with the new token.3
Act on the status
200: show the panel. 403: “this account doesn’t have the admin role”. 401: the API rejected the token. A 401 during use signs the panel out.role = 'admin' on the user’s public.users row (see FAQ).