API

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

SurfaceContains
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/userinfothe same as the id_token, plus ulex claims
SAML assertion attributesa fixed, documented subset — SAML has no claims parameter
/oauth2/introspecta metadata subset, never the profile

A decoded ulex access token:

json
{
  "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

ClaimTypeAlways presentNotes
issstringyeshttps://ulexid.com (or http://127.0.0.1:3001 locally). No trailing slash. Must be compared exactly
substringyesthe ulex usr_… id, stable across email and name changes
audstring | string[]yesthe client_id the token was issued to. An array when the token has been exchanged for multiple audiences
azpstringwhen aud has > 1the authorized party. Check it whenever aud is an array
expintegeryesseconds since epoch. 3,600 s after issuance
iatintegeryesseconds since epoch
nbfintegeraccess tokensequals iat
jtistringyesunique per token. Use it as an idempotency key and in logs
noncestringid_token onlyecho of the authorization nonce. Verify it

#Profile claims — scope must include profile

ClaimTypeSourceNotes
namestringdisplay_name, or first_name + + last_namemay be absent if both are null
given_namestringuser.first_name≤ 80
family_namestringuser.last_name≤ 80
preferred_usernamestringuser.emailalways the email, never a login name
nicknamestringuser.scim.nick_namemay be absent
picturestring—only if your application sets it; ulex has no avatar store
updated_atintegeruser.updated_atseconds since epoch
localestringuser.scim.localeBCP-47
acrstringauthentication contextsee MFA
amrstring[]authentication methodssee below

#Email claims — scope must include email

ClaimTypeSourceNotes
emailstringuser.emaillowercased, trimmed
email_verifiedbooleanuser.email_verifiedfalse 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.

ClaimTypePresent whenNotes
org_idstringthe authorization named an organizationthe one to authorize on. A session is not an authorization
org_slugstringsamehuman-readable, for UI
connection_idstringalwayswhich IdP authenticated this user
sidstringalways, for user flowsthe ulex session. Two tokens from the same login share it
scopestringalwaysthe granted scopes, space separated
client_idstringalwaysduplicate of azp; convenient, not required
amrstring[]alwayshow
acrstringalwayshow strong
amr_detailsobject[]when MFA or passkeys were used{ method, acr?, ts? }
https://ulexid.com/claimsobjectwhen custom claims are configurednamespaced to avoid collision

#org_id and multi-tenancy

ts
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/revoke with revoke_session: true
  • correlate an audit event to a token: GET /audit-events?session_id={sid}
  • invalidate a session on suspension: POST /users/{id}/suspend does this for you

sid is not your application's session id. Do not use it as one.

#amr and acr

amr valueMeaning
pwdpassword
otpTOTP or email one-time code
smsSMS code
webauthnpasskey
pushedpush notification
hwkhardware security key
mfaa second factor was satisfied, in addition to the above
samlfederated through SAML
oidcfederated through upstream OIDC
ldapfederated through LDAP/AD
magic_linkmagic link
urn:ulex:amr:simulatedulex_mint_access_token. Not an authentication
acrMeaning
urn:ulex:acr:pwdpassword only
urn:ulex:acr:otppassword plus one-time code
urn:ulex:acr:mfapassword plus a second factor
urn:ulex:acr:phishing-resistantpasskey or hardware key
urn:ulex:acr:simulatedforged 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:

json
{
  "custom_claims": {
    "org_role": { "source": "membership.role" },
    "groups": { "source": "groups", "claim": "slug" },
    "tenant_tier": { "source": "organization.metadata.plan_tier" }
  }
}

Requested at authorization time:

http
GET /api/v1/oauth2/authorize?...&claims={"id_token":{"org_role":null,"groups":null},"access_token":{"tenant_tier":null}}

They arrive namespaced:

json
"https://ulexid.com/claims": {
  "org_role": "owner",
  "groups": ["engineering"],
  "tenant_tier": "enterprise"
}
SourceResolves to
membership.rolethe user's role in the current organization
groupsgroup 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.

Warning

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.

Attributeulex sourceAlways present
emailuser.emailyes
firstNameuser.first_nameno
lastNameuser.last_nameno
displayNameuser.display_nameno
titleuser.job_titleno
departmentuser.departmentno
groupsgroup slugs, repeatedno
org_idthe organizationyes
org_slugthe organization slugyes
org_roleowner/admin/member/guestyes
sidthe ulex sessionyes
auth_timeepoch secondsyes
acralso in AuthnContextClassRefyes
amrrepeated, one element per methodno

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:

json
{
  "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"
}
FieldNotes
activefalse for unknown, expired, revoked, or family-killed tokens. 200, never 401
token_typeaccess_token, refresh_token, id_token
scopespace separated
client_idthe application the token was issued to
subabsent for a client-credentials token
org_idabsent if the authorization named no organization
auth_timewhen the user actually authenticated, as opposed to iat
amr, acras in the token
nbfpresent when present in the token
username, client_secretnever. 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.

ts
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:

ts
// 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.
Warning

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.

#Reference