OIDC claim reference
Every claim ulex issues in an access token, id_token, userinfo response, and SAML assertion: which scope unlocks it, its exact type, when it is present, and how to request custom claims.
#Where claims appear
| Surface | Contains |
|---|---|
access_token (JWT payload) | registered claims, ulex claims, amr/acr, custom claims |
id_token (JWT payload) | registered claims, profile and email claims, sid, acr, amr |
/oauth2/userinfo | the same as the id_token, plus ulex claims |
| SAML assertion attributes | a fixed, documented subset — SAML has no claims parameter |
/oauth2/introspect | a metadata subset, never the profile |
A decoded ulex access token:
{
"iss": "https://ulexid.com",
"sub": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
"aud": ["client_01M3PSV7J8TBSPHG95CYSEX32B"],
"azp": "client_01M3PSV7J8TBSPHG95CYSEX32B",
"exp": 1790696712,
"iat": 1790693112,
"nbf": 1790693112,
"jti": "jti_01M3PSWB2KJ8XQ4RD7T5V6W8Y0Z",
"client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
"org_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
"org_slug": "acme",
"connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
"scope": "openid profile email offline_access",
"sid": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
"amr": ["pwd", "otp", "mfa"],
"acr": "urn:ulex:acr:mfa",
"amr_details": [
{ "method": "pwd", "acr": "urn:ulex:acr:pwd" },
{ "method": "webauthn", "acr": "urn:ulex:acr:mfa", "ts": 1790693112 }
],
"https://ulexid.com/claims": { "org_role": "owner", "groups": ["engineering"] }
}#Registered claims
| Claim | Type | Always present | Notes |
|---|---|---|---|
iss | string | yes | https://ulexid.com (or http://127.0.0.1:3001 locally). No trailing slash. Must be compared exactly |
sub | string | yes | the ulex usr_… id, stable across email and name changes |
aud | string | string[] | yes | the client_id the token was issued to. An array when the token has been exchanged for multiple audiences |
azp | string | when aud has > 1 | the authorized party. Check it whenever aud is an array |
exp | integer | yes | seconds since epoch. 3,600 s after issuance |
iat | integer | yes | seconds since epoch |
nbf | integer | access tokens | equals iat |
jti | string | yes | unique per token. Use it as an idempotency key and in logs |
nonce | string | id_token only | echo of the authorization nonce. Verify it |
#Profile claims — scope must include profile
| Claim | Type | Source | Notes |
|---|---|---|---|
name | string | display_name, or first_name + + last_name | may be absent if both are null |
given_name | string | user.first_name | ≤ 80 |
family_name | string | user.last_name | ≤ 80 |
preferred_username | string | user.email | always the email, never a login name |
nickname | string | user.scim.nick_name | may be absent |
picture | string | — | only if your application sets it; ulex has no avatar store |
updated_at | integer | user.updated_at | seconds since epoch |
locale | string | user.scim.locale | BCP-47 |
acr | string | authentication context | see MFA |
amr | string[] | authentication methods | see below |
#Email claims — scope must include email
| Claim | Type | Source | Notes |
|---|---|---|---|
email | string | user.email | lowercased, trimmed |
email_verified | boolean | user.email_verified | false for a JIT-provisioned user from an IdP that does not assert it |
email as an array | — | — | not used. ulex always emits a single string, not email: [primary, …] |
email_verified: false with email present is the single most common integration surprise. Entra does not assert it. Either set it explicitly after JIT, or do not gate anything on it and use the connection_id claim instead.
#ulex claims
Present in the access token and in /userinfo; not in the id_token.
| Claim | Type | Present when | Notes |
|---|---|---|---|
org_id | string | the authorization named an organization | the one to authorize on. A session is not an authorization |
org_slug | string | same | human-readable, for UI |
connection_id | string | always | which IdP authenticated this user |
sid | string | always, for user flows | the ulex session. Two tokens from the same login share it |
scope | string | always | the granted scopes, space separated |
client_id | string | always | duplicate of azp; convenient, not required |
amr | string[] | always | how |
acr | string | always | how strong |
amr_details | object[] | when MFA or passkeys were used | { method, acr?, ts? } |
https://ulexid.com/claims | object | when custom claims are configured | namespaced to avoid collision |
#org_id and multi-tenancy
export function authorize(claims: AccessTokenClaims, allowedOrgIds: string[]): void {
if (!claims.org_id) throw new Error("token carries no org_id; the authorization named no organization");
if (!allowedOrgIds.includes(claims.org_id)) {
// 403, and audit it. Do not fall back to "any org they are a member of".
throw new Error(`org ${claims.org_id} is not permitted for this subject`);
}
}A user with memberships in three organizations gets one org_id per authorization, chosen by the organization parameter on /oauth2/authorize. There is no multi-org access token; issue one per org if you need both.
#sid
sid is the ulex session. Use it to:
- revoke every token a user holds across applications:
POST /oauth2/revokewithrevoke_session: true - correlate an audit event to a token:
GET /audit-events?session_id={sid} - invalidate a session on suspension:
POST /users/{id}/suspenddoes this for you
sid is not your application's session id. Do not use it as one.
#amr and acr
amr value | Meaning |
|---|---|
pwd | password |
otp | TOTP or email one-time code |
sms | SMS code |
webauthn | passkey |
pushed | push notification |
hwk | hardware security key |
mfa | a second factor was satisfied, in addition to the above |
saml | federated through SAML |
oidc | federated through upstream OIDC |
ldap | federated through LDAP/AD |
magic_link | magic link |
urn:ulex:amr:simulated | ulex_mint_access_token. Not an authentication |
acr | Meaning |
|---|---|
urn:ulex:acr:pwd | password only |
urn:ulex:acr:otp | password plus one-time code |
urn:ulex:acr:mfa | password plus a second factor |
urn:ulex:acr:phishing-resistant | passkey or hardware key |
urn:ulex:acr:simulated | forged by the simulator |
Branch on acr, not amr. amr is a history; acr is a verdict. Full detail: MFA and passkeys.
#Custom claims
Configure on the application:
{
"custom_claims": {
"org_role": { "source": "membership.role" },
"groups": { "source": "groups", "claim": "slug" },
"tenant_tier": { "source": "organization.metadata.plan_tier" }
}
}Requested at authorization time:
GET /api/v1/oauth2/authorize?...&claims={"id_token":{"org_role":null,"groups":null},"access_token":{"tenant_tier":null}}They arrive namespaced:
"https://ulexid.com/claims": {
"org_role": "owner",
"groups": ["engineering"],
"tenant_tier": "enterprise"
}| Source | Resolves to |
|---|---|
membership.role | the user's role in the current organization |
groups | group slugs; claim: "slug" (default) or claim: "id" |
user.<field> | any ulex user field, e.g. user.department |
organization.<field> | any organization field, e.g. organization.slug |
organization.metadata.<key> | a flat metadata key |
connection.<field> | any connection field except config secrets |
A source that resolves to nothing produces an absent claim, not null. Code that assumes presence will crash on the first user without a department. Use optional chaining.
Never put PHI, a secret, a raw token, or a full profile into a custom claim. Claims are readable by anyone holding the token, they are logged by every JWT library at debug level, and they cannot be revoked before exp.
#SAML assertion attributes
SAML has no claims parameter, so the attribute set is fixed. The list is in the application's SP metadata AttributeConsumingService.
| Attribute | ulex source | Always present |
|---|---|---|
email | user.email | yes |
firstName | user.first_name | no |
lastName | user.last_name | no |
displayName | user.display_name | no |
title | user.job_title | no |
department | user.department | no |
groups | group slugs, repeated | no |
org_id | the organization | yes |
org_slug | the organization slug | yes |
org_role | owner/admin/member/guest | yes |
sid | the ulex session | yes |
auth_time | epoch seconds | yes |
acr | also in AuthnContextClassRef | yes |
amr | repeated, one element per method | no |
Custom claims are not emitted in SAML assertions. If you need tenant_tier in a SAML app, encode it in a group.
#Introspection
/oauth2/introspect returns a metadata subset, never the profile:
{
"active": true,
"token_type": "access_token",
"scope": "openid profile email offline_access",
"client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
"sub": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
"org_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
"sid": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
"exp": 1790696712,
"iat": 1790693112,
"auth_time": 1790693112,
"amr": ["pwd", "otp", "mfa"],
"acr": "urn:ulex:acr:mfa"
}| Field | Notes |
|---|---|
active | false for unknown, expired, revoked, or family-killed tokens. 200, never 401 |
token_type | access_token, refresh_token, id_token |
scope | space separated |
client_id | the application the token was issued to |
sub | absent for a client-credentials token |
org_id | absent if the authorization named no organization |
auth_time | when the user actually authenticated, as opposed to iat |
amr, acr | as in the token |
nbf | present when present in the token |
username, client_secret | never. RFC 7662 defines them; ulex deliberately does not return them |
#Validation order
Do it in this order and stop at the first failure. Every step has a distinct failure mode and a distinct log line.
import { createLocalJWKSet, jwtVerify } from "jose";
const jwks = createLocalJWKSet(
await (await fetch(`${ISSUER}/api/v1/oauth2/keys`)).json(),
);
export async function verifyAccessToken(token: string, expectedClientId: string) {
// 1. signature, keyed by kid — also validates the algorithm against the allow-list
const { payload, protectedHeader } = await jwtVerify(token, jwks, {
issuer: ISSUER, // 2. iss, exact string
audience: expectedClientId, // 3. aud contains the client_id
algorithms: ["RS256"], // never "none", never from the token
clockTolerance: 30, // 4/5. exp and nbf, with 30s slack
});
// 6. azp when aud has more than one entry
const aud = Array.isArray(payload.aud) ? payload.aud : [payload.aud as string];
if (aud.length > 1 && payload.azp !== expectedClientId) {
throw new Error(`azp ${payload.azp} does not match the expected client`);
}
// 7. alg confusion: the header's alg must be what you allowed, and must
// not be "none" or a symmetric algorithm.
if (protectedHeader.alg === "none") throw new Error("alg=none is never valid");
return { sub: payload.sub!, orgId: payload.org_id, sid: payload.sid, acr: payload.acr, amr: payload.amr, jti: payload.jti! };
}Then, for authorization:
// 8. The org is in the token, not in a session you looked up earlier.
if (claims.orgId !== expectedOrgId) throw new Error("wrong organization");
// 9. Only for high-risk operations:
if (claims.acr !== "urn:ulex:acr:mfa" && claims.acr !== "urn:ulex:acr:phishing-resistant") {
throw new Error("this action requires MFA");
}
// 10. If you need revocation now, introspect. The signature alone cannot tell you.Step 10 is the one people skip. A suspended user's access token remains cryptographically valid until exp. Signature verification will not tell you. Either introspect, or keep access-token lifetimes short, or call POST /oauth2/revoke per token when you suspend someone.