Configuring Authentication in Supamode
Set up secure authentication for Supamode admin accounts. Learn about the two-layer auth system, MFA enforcement, captcha protection, and how to grant admin access to users.
Supamode uses a two-layer authentication system to control admin access. Users must pass both checks before accessing any admin functionality.
Authentication Layers
Layer 1: JWT Metadata Check
The first layer is a fast, lightweight check that reads the user's JWT token. Users must have supamode_access: true in their app_metadata to pass this check.
This check runs:
- On every API request via Hono middleware
- On database operations via the
supamode.check_supamode_access()function
The JWT check filters out unauthorized users before any database queries run, reducing load on your database.
Layer 2: Account and Role Verification
The second layer verifies the user exists in supamode.accounts and has an assigned role with appropriate permissions.
This check validates:
- The account exists and is active (
is_active: true) - A role is assigned to the account
- The role has permissions for the requested operation
Without both layers passing, users see an access denied error.
Adding Admin Users
You have two options for granting admin access:
Option 1: Using the Supamode UI (Recommended)
This is the easiest approach for adding admins after initial setup.
Prerequisites: The user must already have a Supabase Auth account in your application.
Steps:
- Navigate to the Users Explorer in Supamode
- Search for the user by email
- Click on their email to open their profile
- Click the Make Admin button in the top right

- Confirm the action in the dialog

- Assign a role to the new admin (required for any access)
The "Make Admin" action does two things:
- Sets
supamode_access: truein the user's JWTapp_metadata - Creates a record in
supamode.accounts
Without a role assignment, the user can log in but cannot access any data or features.
Option 2: Using Seed Files
For initial setup or automated deployments, use seed templates to create accounts with roles pre-assigned.
const adminAccount = Account.create({ app, id: 'user-uuid-from-supabase-auth',});adminAccount.assignRole(adminRole);See the RBAC System documentation for complete seed file examples.
Removing Admin Access
To revoke admin access for a user:
- Navigate to the user's profile in the Users Explorer
- Click Remove Admin Access
This action:
- Sets
supamode_access: falsein their JWT - Marks the account as inactive in
supamode.accounts
The user can no longer access Supamode, but their Supabase Auth account remains intact.
Multi-Factor Authentication
MFA adds a second authentication factor (typically a TOTP app like Google Authenticator) beyond the password. We recommend enabling MFA for all admin accounts.
Setting Up MFA for Your Account
- Navigate to
/settings/authentication - Click Enable MFA
- Scan the QR code with your authenticator app
- Enter the verification code to confirm

Enforcing MFA for All Admins
After enabling MFA on your own account, you can require it for all admin users:
- Navigate to
/settings/authentication - Enable Require MFA for all users

Coordinate MFA Rollout
Before enforcing MFA, ensure all existing admins have set up their authenticator apps. Users without MFA configured will be locked out until they complete setup.
If you're using a MakerKit application, MFA flows are already built into your authentication pages.
Captcha Protection
Cloudflare Turnstile captcha prevents automated attacks on login and signup pages.
Configuration
Add these environment variables to your frontend configuration:
VITE_CAPTCHA_SITE_KEY="0x4AAAAAAAB..."Server-side, you need the CAPTCHA_SECRET_TOKEN environment variable:
CAPTCHA_SECRET_TOKEN="0x4AAAAAAAB..."To get a Turnstile site key:
- Go to Cloudflare Dashboard
- Create a new Turnstile widget
- Add your domain to allowed hostnames
- Copy the Site Key
Once configured, captcha automatically appears on:
- Login page
- Signup page
- Password reset page
Security Headers and CSRF Protection
Supamode's Hono API includes security protections by default:
- CORS: Configured via
APP_URLenvironment variable. Only requests from your frontend domain are allowed. - CSRF Protection: Built into all mutating endpoints. Tokens are automatically managed.
- Secure Headers: Standard security headers (X-Frame-Options, X-Content-Type-Options, etc.) are set on all responses.
No additional configuration is required for these protections.
Troubleshooting
"Access Denied" After Making User Admin
- Verify the user has a role assigned (not just admin status)
- Check the role has appropriate permissions
- Have the user log out and back in to refresh their JWT
MFA Code Not Working
- Verify time synchronization on the user's device
- Ensure they're using the correct authenticator account
- If locked out, an admin with higher rank can disable MFA temporarily
User Can't See Any Tables
This usually means their role lacks data permissions. Check that:
- The role is assigned to their account
- The role has data permissions for the required tables
- The user has refreshed their session after role assignment