Skip to main content
The CREDEBL platform API uses JWT Bearer tokens issued by Keycloak. Every protected endpoint requires an Authorization: Bearer <token> header. Tokens are signed with RS256 and verified against the Keycloak JWKS endpoint derived from the token’s iss claim.
The platform supports three authentication methods: Supabase-backed email/password (primary), Keycloak SSO (for multi-client deployments), and FIDO/WebAuthn passkeys. All methods ultimately produce a Keycloak-issued JWT.

Registration and login flow

1

Request a verification email

Send the user’s email address to receive a one-time verification code.
An optional clientAlias query parameter targets a specific SSO client. If omitted, the default client is used.
2

Verify the email address

Confirm the verification code delivered to the user’s inbox.
curl
3

Complete registration

Submit the user’s profile details to create the account.
curl
4

Sign in

Exchange credentials for a JWT access token and a refresh token.
5

Call protected endpoints

Include the token in the Authorization header for every subsequent request.
curl

Token refresh

Access tokens expire after the duration specified in expires_in (seconds). Use the refresh token returned at sign-in to obtain a new access token without requiring the user to re-authenticate.
Store refresh tokens securely. A leaked refresh token allows an attacker to obtain new access tokens until the session is revoked.

Sign out

Invalidate the current session server-side. Requires a valid Bearer token.
curl

Password reset

Request a password-reset link sent to the user’s email.
curl

Auth providers

Supabase is the primary identity backend. The platform uses SUPABASE_URL, SUPABASE_KEY, and SUPABASE_JWT_SECRET to verify tokens and manage user records.Set these three variables in .env:
.env
SUPABASE_JWT_SECRET is used for server-side token verification. Never expose it in client-side code.

Multi-client SSO (clientAlias)

The platform can serve multiple front-end clients from a single backend. Each client has its own Keycloak management credentials and post-login redirect domain. The clientAlias concept ties a request to a specific client. How it works:
  1. SUPPORTED_SSO_CLIENTS lists all enabled client names (comma-separated).
  2. For each name, four environment variables are expected:
    • {NAME}_CLIENT_ALIAS — short alias token
    • {NAME}_DOMAIN — post-login redirect URL
    • {NAME}_KEYCLOAK_MANAGEMENT_CLIENT_ID — encrypted client ID
    • {NAME}_KEYCLOAK_MANAGEMENT_CLIENT_SECRET — encrypted client secret
  3. The GET /auth/clientAliases endpoint returns all configured aliases and their domains.
  4. Auth endpoints that accept a clientAlias query parameter (e.g., POST /auth/verification-mail) use the alias to select the correct Keycloak client for the operation.
Example: adding a second client
.env
CREDEBL_KEYCLOAK_MANAGEMENT_CLIENT_ID and _SECRET values must be encrypted using CRYPTO_PRIVATE_KEY before being stored in .env. Use the same encryption key as configured in the Studio UI.

Session management

The platform tracks sessions server-side. A sid claim in the JWT is validated against the session store on every authenticated request (see JwtStrategy.validate). A token whose session has been revoked is rejected with 401 Unauthorized.
Users can only view and revoke their own sessions. Attempting to access another user’s sessions returns 403 Forbidden.

HTTP error reference