Endpoints

MethodPathAuthDescription
POST/api/v1/auth/real/loginNoneUsername + password (bcrypt). Returns JWT access token. If MFA enabled, returns mfa_required: true + mfa_token instead.
POST/api/v1/auth/real/mfa/verifyMFA tokenSubmit 6-digit TOTP code to complete MFA login. Returns full JWT access token on success.
POST/api/v1/auth/real/mfa/setupBearerEnrol MFA — returns TOTP secret + QR code URI + backup codes. User must verify once to activate.
DELETE/api/v1/auth/real/mfa/disableBearer + TOTPDisable MFA on the authenticated account. Requires a valid TOTP code to confirm.
POST/api/v1/auth/real/forgot-passwordNoneSend a 6-digit OTP to the user's email. OTP valid for 10 minutes. Rate-limited.
POST/api/v1/auth/real/reset-passwordNoneExchange OTP for a password reset. Requires email, otp, new_password.
POST/api/v1/auth/real/registerNoneSelf-registration (if enabled). Creates account pending admin approval or auto-approved depending on config.
POST/api/v1/auth/refreshBearerExchange a valid token for a new one (token refresh). Clears old session from Valkey.
POST/api/v1/auth/logoutBearerInvalidate the current session (deletes Valkey key for jti).
GET/api/v1/auth/sso/initNoneRedirect to configured SSO IdP. Param: ?provider=saml|oidc|google|github|azure
POST/api/v1/auth/sso/callbackNoneSSO assertion callback > issues JWT, redirects to portal
GET/api/v1/auth/meBearerCurrent authenticated user profile + active access group
GET/api/v1/auth/real/usersAdmin BearerList all users (paginated)
POST/api/v1/auth/real/usersAdmin BearerCreate a new user
PATCH/api/v1/auth/real/users/{user_id}Admin BearerUpdate user (role, access group, email, display name)
DELETE/api/v1/auth/real/users/{user_id}Admin BearerDeactivate user (soft delete — retained in audit log)
DELETE/api/v1/auth/sessions/{user_id}Admin BearerForce-revoke all sessions for a user (purges Valkey keys)

Login & Token Flow

# Login — returns access_token and sets httpOnly refresh cookie
curl -s -X POST http://localhost:8200/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -c cookies.txt \
  -d '{"username": "admin", "password": "'"$VELARIS_ADMIN_PASSWORD"'"}'

# Response
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer",
  "expires_in": 900
}

# Use the token
export TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

# Refresh (uses httpOnly cookie automatically)
curl -s -X POST http://localhost:8200/api/v1/auth/refresh \
  -b cookies.txt -c cookies.txt

JWT Payload Claims

ClaimTypeDescription
subUUID stringUser ID (primary identifier)
jtiUUID stringJWT ID — unique per token. Used as the Valkey session key for revocation (session:{user_id}:{jti}). Logout and forced-logout operations target this key.
rolestringUser role (admin/developer/manager/agent/customer/auditor)
rolesstring[]All roles assigned to the user (P37 enriched from access group)
access_group_idstringActive access group ID
tenant_idstringTenant namespace (default: "default")
issstringIssuer — set by AUTH_ISSUER env var
audstringAudience — set by AUTH_AUDIENCE env var
iatUnix timestampIssued-at time
expUnix timestampExpiry time

User Management Examples

# Create user (admin token required)
curl -s -X POST http://localhost:8200/api/v1/auth/real/users \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "jane.smith",
    "email": "jane@company.com",
    "password": "TempPass123!",
    "role": "agent",
    "access_group_id": "group-finance"
  }'

# Update user role
curl -s -X PATCH http://localhost:8200/api/v1/auth/real/users/{user_id} \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role": "manager"}'

JWT Signing Configuration

Velaris supports three JWT modes. Set via environment variables on case-service:

ModeEnv Vars RequiredRecommendation
HS256 (symmetric)AUTH_SECRETDevelopment only. Every service holding AUTH_SECRET can mint tokens.
RS256 (asymmetric)VELARIS_CASE_AUTH_RSA_PRIVATE_KEY + VELARIS_CASE_AUTH_RSA_PUBLIC_KEYRecommended for production. Only the auth service needs the private key. All other services verify with public key only. RS256 activates automatically when both keys are present.
OIDC (external IdP)AUTH_OIDC_ISSUER + AUTH_OIDC_AUDIENCEDelegate token issuance to Keycloak / Auth0 / Authentik. Velaris validates using the IdP's JWKS endpoint.
# Generate RS256 key pair (run once)
openssl genrsa -out private.pem 4096
openssl rsa -in private.pem -pubout -out public.pem

# Add to .env
VELARIS_CASE_AUTH_RSA_PRIVATE_KEY="$(cat private.pem)"
VELARIS_CASE_AUTH_RSA_PUBLIC_KEY="$(cat public.pem)"

MFA Login Flow

# Step 1 — password login (MFA enabled user)
curl -s -X POST http://localhost:8200/api/v1/auth/real/login \
  -H "Content-Type: application/json" \
  -d '{"email": "admin@velaris.io", "password": "secret"}'

# Response when MFA is required:
{ "mfa_required": true, "mfa_token": "tmp-token-uuid" }

# Step 2 — submit TOTP code
curl -s -X POST http://localhost:8200/api/v1/auth/real/mfa/verify \
  -H "Content-Type: application/json" \
  -d '{"mfa_token": "tmp-token-uuid", "totp_code": "123456"}'

# Response: full access token
{ "access_token": "eyJ...", "token_type": "bearer" }

SSO Configuration

SSO is configured in the database, not in environment variables. There is no SSO_ENABLED, SSO_METADATA_URL or SSO_ACS_URL setting — nothing to put in .env and nothing to restart. A provider is a row in sso_providers, created under Studio → Admin Console → SSO, and it takes effect as soon as it is saved.
EndpointPrivilegePurpose
GET /auth/real/sso/providers— publicWhat the login page renders: provider, button label, icon, and a SAML row's login URL. Never discloses tenant_id, config, or disabled rows.
GET /auth/real/sso/providers/manageidentity.sso.readAdmin listing — every row with its config, plus certificate expiry for SAML. The client secret is never returned in any form.
POST /auth/real/sso/providersidentity.sso.configureCreate. Refuses a provider the callback could not service.
PATCH /auth/real/sso/providers/{id}identity.sso.configureEdit. A blank secret means “keep the stored one”; provider itself is not patchable.
DELETE /auth/real/sso/providers/{id}identity.sso.configureRemove.
POST /auth/saml/metadata/parseidentity.sso.readRead an IdP's federation metadata from a URL or pasted XML and return its fields. Saves nothing.

For a non-preset OIDC provider the endpoints live on the row's config: auth_url, token_url, userinfo, scope, and optionally emails for a GitHub-shaped verified-email list. All are https-only and SSRF-checked. google and github are built in and cannot be repointed by editing config.

SAML has its own page: SAML SSO Setup — Okta and Microsoft Entra ID.

Error Codes

CodeMeaning
401Invalid credentials (login) or expired/invalid token
403Insufficient role for the requested operation
409Username or email already exists
410User account deactivated — contact admin
423Account locked due to too many failed attempts. Locked for 15 minutes. Unlock manually via admin or wait for the window to expire.
429Rate limit exceeded (too many requests from this IP)