🚧 FastCMS is under active development — not ready for production use. APIs and features may change without notice.
FastCMS
Authentication

Authentication

FastCMS provides a comprehensive authentication system with JWT, OAuth, 2FA, OTP passwordless login, session management, and support for custom user collections.

Authentication

FastCMS provides a comprehensive authentication system with multiple configurable auth methods and support for custom user collections.

localhost:8000/admin/users

Users

Manage user accounts and permissions

Total: 142 users
Page 1 of 8
UserEmailRoleStatusCreatedActions
A

Admin User

usr_admin

admin@example.comadminVerified2026-01-15
J

John Smith

usr_john

john@acme.comuserVerified2026-02-01
S

Sara Jones

usr_sara

sara@startup.iouserVerified2026-02-10
D

Dev Account

usr_dev

dev@company.comadminVerified2026-02-14
N

No name

usr_new

new@user.netuserUnverified2026-03-01

Authentication Methods

MethodSettingDescription
Passwordpassword_auth_enabledTraditional email/password login
OAuth2oauth_enabledSocial login (Google, GitHub, etc.)
OTPotp_enabledEmail code authentication
MFAmfa_enabledMulti-factor authentication

1. Built-in Admin Authentication

The users table is for admin dashboard access only.

Endpoints:

EndpointMethodDescription
/api/v1/auth/loginPOSTAdmin login
/api/v1/auth/registerPOSTCreate admin users
/api/v1/auth/refreshPOSTRefresh access token
/api/v1/auth/meGETGet current user info
/api/v1/auth/logoutPOSTLogout (invalidate tokens)

Login Example:

curl -X POST http://localhost:8000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "password": "your-password"
  }'

Response:

{
  "access_token": "eyJhbGc...",
  "refresh_token": "eyJhbGc...",
  "token_type": "bearer",
  "user": {
    "id": "uuid",
    "email": "admin@example.com",
    "role": "admin",
    "verified": true
  }
}

2. Auth Collections (Custom User Systems)

Create auth collections for your own user systems — customers, vendors, students, etc.

Creating an Auth Collection

curl -X POST http://localhost:8000/api/v1/collections \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ADMIN_TOKEN" \
  -d '{
    "name": "customers",
    "type": "auth",
    "schema": {
      "fields": [
        {"name": "company", "type": "text"},
        {"name": "phone", "type": "text"}
      ]
    }
  }'

Auth Collection Endpoints

For a collection named customers:

EndpointMethodDescription
/api/v1/collections/customers/auth/registerPOSTCustomer registration
/api/v1/collections/customers/auth/loginPOSTCustomer login
/api/v1/collections/customers/auth/refreshPOSTRefresh token
/api/v1/collections/customers/auth/meGETGet current customer
/api/v1/collections/customers/auth/me/change-passwordPOSTChange password
/api/v1/collections/customers/auth/me/request-email-changePOSTRequest email change
/api/v1/collections/customers/auth/me/confirm-email-changePOSTConfirm email change
/api/v1/collections/customers/auth/otp/requestPOSTRequest OTP code
/api/v1/collections/customers/auth/otp/verifyPOSTVerify OTP
/api/v1/collections/customers/auth/sessionsGETList active sessions
/api/v1/collections/customers/auth/sessions/{id}DELETERevoke a session
/api/v1/collections/customers/auth/sessions/allDELETELogout all devices

Registration:

curl -X POST http://localhost:8000/api/v1/collections/customers/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "customer@example.com",
    "password": "securepassword123",
    "company": "Acme Inc",
    "phone": "+1234567890"
  }'

OTP / Passwordless Login

OTP (One-Time Password) lets users log in with a code sent to their email — no password required.

Enable it per-collection in settings (otp_enabled: true).

Step 1: Request a code

curl -X POST http://localhost:8000/api/v1/collections/customers/auth/otp/request \
  -H "Content-Type: application/json" \
  -d '{"email": "customer@example.com"}'

FastCMS sends a 6-digit code to the email address. Codes are valid for 10 minutes.

Step 2: Verify the code

curl -X POST http://localhost:8000/api/v1/collections/customers/auth/otp/verify \
  -H "Content-Type: application/json" \
  -d '{
    "email": "customer@example.com",
    "code": "483921"
  }'

Response: Same token format as regular login (access_token, refresh_token, user).

OTP and password login can coexist — both are available when enabled.

Email Change

Users can update their email address with a two-step verified flow:

Step 1: Request the change (must be authenticated)

curl -X POST http://localhost:8000/api/v1/collections/customers/auth/me/request-email-change \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "new_email": "new@example.com",
    "password": "current_password"
  }'

FastCMS sends a verification link to the new email address.

Step 2: Confirm with the token from the email

curl -X POST http://localhost:8000/api/v1/collections/customers/auth/me/confirm-email-change \
  -H "Content-Type: application/json" \
  -d '{"token": "verification-token-from-email"}'

The email is updated only after this confirmation step.

Session Management

Every login creates a tracked session. Users can view and revoke active sessions across devices.

List active sessions:

curl http://localhost:8000/api/v1/collections/customers/auth/sessions \
  -H "Authorization: Bearer ACCESS_TOKEN"
[
  {
    "id": "session-uuid",
    "created": "2026-03-01T10:00:00Z",
    "last_used": "2026-03-02T08:30:00Z",
    "user_agent": "Mozilla/5.0..."
  }
]

Revoke a specific session:

curl -X DELETE \
  http://localhost:8000/api/v1/collections/customers/auth/sessions/session-uuid \
  -H "Authorization: Bearer ACCESS_TOKEN"

Logout all devices:

curl -X DELETE \
  http://localhost:8000/api/v1/collections/customers/auth/sessions/all \
  -H "Authorization: Bearer ACCESS_TOKEN"

Using Authentication Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
const response = await fetch('/api/v1/collections/products/records', {
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  }
});

Token Refresh

When the access token expires, use the refresh token:

curl -X POST http://localhost:8000/api/v1/auth/refresh \
  -H "Content-Type: application/json" \
  -d '{"refresh_token": "eyJhbGc..."}'

Authentication Settings

Configure via Admin > Settings > Authentication or via API:

Auth Methods

SettingDefaultDescription
password_auth_enabledtrueEnable password authentication
oauth_enabledtrueEnable OAuth2
otp_enabledfalseEnable OTP (email code)
mfa_enabledfalseEnable Multi-Factor Authentication

Password Requirements

SettingDefaultDescription
password_min_length8Minimum password length
password_require_upperfalseRequire uppercase letter
password_require_numberfalseRequire number
password_require_specialfalseRequire special character

Token Settings

SettingDefaultDescription
token_expiry_hours24Access token expiry
refresh_token_expiry_days7Refresh token expiry

Security Best Practices

  1. Use HTTPS — always use HTTPS in production
  2. Token Storage — store tokens in httpOnly cookies
  3. Short Expiry — use short access token expiry with refresh tokens
  4. Password Requirements — enable complexity requirements for production
  5. Rate Limiting — enabled by default to prevent brute force attacks

Next Steps

On this page