The Auth API handles credential verification, JWT issuance, SSO callbacks, and user management. It is built into case-service and reached through the API gateway on port 8200 — there is no separate auth service. It is the single source of truth for identity in Velaris.
| Method | Path | Auth | Description |
|---|---|---|---|
POST | /api/v1/auth/real/login | None | Username + password (bcrypt). Returns JWT access token. If MFA enabled, returns mfa_required: true + mfa_token instead. |
POST | /api/v1/auth/real/mfa/verify | MFA token | Submit 6-digit TOTP code to complete MFA login. Returns full JWT access token on success. |
POST | /api/v1/auth/real/mfa/setup | Bearer | Enrol MFA — returns TOTP secret + QR code URI + backup codes. User must verify once to activate. |
DELETE | /api/v1/auth/real/mfa/disable | Bearer + TOTP | Disable MFA on the authenticated account. Requires a valid TOTP code to confirm. |
POST | /api/v1/auth/real/forgot-password | None | Send a 6-digit OTP to the user's email. OTP valid for 10 minutes. Rate-limited. |
POST | /api/v1/auth/real/reset-password | None | Exchange OTP for a password reset. Requires email, otp, new_password. |
POST | /api/v1/auth/real/register | None | Self-registration (if enabled). Creates account pending admin approval or auto-approved depending on config. |
POST | /api/v1/auth/refresh | Bearer | Exchange a valid token for a new one (token refresh). Clears old session from Valkey. |
POST | /api/v1/auth/logout | Bearer | Invalidate the current session (deletes Valkey key for jti). |
GET | /api/v1/auth/sso/init | None | Redirect to configured SSO IdP. Param: ?provider=saml|oidc|google|github|azure |
POST | /api/v1/auth/sso/callback | None | SSO assertion callback > issues JWT, redirects to portal |
GET | /api/v1/auth/me | Bearer | Current authenticated user profile + active access group |
GET | /api/v1/auth/real/users | Admin Bearer | List all users (paginated) |
POST | /api/v1/auth/real/users | Admin Bearer | Create a new user |
PATCH | /api/v1/auth/real/users/{user_id} | Admin Bearer | Update user (role, access group, email, display name) |
DELETE | /api/v1/auth/real/users/{user_id} | Admin Bearer | Deactivate user (soft delete — retained in audit log) |
DELETE | /api/v1/auth/sessions/{user_id} | Admin Bearer | Force-revoke all sessions for a user (purges Valkey keys) |
# 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
| Claim | Type | Description |
|---|---|---|
sub | UUID string | User ID (primary identifier) |
jti | UUID string | JWT ID — unique per token. Used as the Valkey session key for revocation (session:{user_id}:{jti}). Logout and forced-logout operations target this key. |
role | string | User role (admin/developer/manager/agent/customer/auditor) |
roles | string[] | All roles assigned to the user (P37 enriched from access group) |
access_group_id | string | Active access group ID |
tenant_id | string | Tenant namespace (default: "default") |
iss | string | Issuer — set by AUTH_ISSUER env var |
aud | string | Audience — set by AUTH_AUDIENCE env var |
iat | Unix timestamp | Issued-at time |
exp | Unix timestamp | Expiry time |
# 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"}'
Velaris supports three JWT modes. Set via environment variables on case-service:
| Mode | Env Vars Required | Recommendation |
|---|---|---|
| HS256 (symmetric) | AUTH_SECRET | Development only. Every service holding AUTH_SECRET can mint tokens. |
| RS256 (asymmetric) | VELARIS_CASE_AUTH_RSA_PRIVATE_KEY + VELARIS_CASE_AUTH_RSA_PUBLIC_KEY | Recommended 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_AUDIENCE | Delegate 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)"
# 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_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.| Endpoint | Privilege | Purpose |
|---|---|---|
GET /auth/real/sso/providers | — public | What 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/manage | identity.sso.read | Admin listing — every row with its config, plus certificate expiry for SAML. The client secret is never returned in any form. |
POST /auth/real/sso/providers | identity.sso.configure | Create. Refuses a provider the callback could not service. |
PATCH /auth/real/sso/providers/{id} | identity.sso.configure | Edit. A blank secret means “keep the stored one”; provider itself is not patchable. |
DELETE /auth/real/sso/providers/{id} | identity.sso.configure | Remove. |
POST /auth/saml/metadata/parse | identity.sso.read | Read 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.
| Code | Meaning |
|---|---|
| 401 | Invalid credentials (login) or expired/invalid token |
| 403 | Insufficient role for the requested operation |
| 409 | Username or email already exists |
| 410 | User account deactivated — contact admin |
| 423 | Account locked due to too many failed attempts. Locked for 15 minutes. Unlock manually via admin or wait for the window to expire. |
| 429 | Rate limit exceeded (too many requests from this IP) |