Resources

SAML issues

Diagnosing ulex SAML: the seven failure modes, what each means, the verification checklist, certificate rotation, clock skew, attribute mapping, replay, and a headless way to reproduce a customer's IdP behaviour.

#Start here

bash
BASE="https://ulexid.com/api/v1"
AUTH="Authorization: Bearer $ULEX_API_KEY"

# 1. Does the connection validate?
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" \
  | jq '{valid, failing: [.checks[] | select(.status == "failed")] }'

# 2. What happened on the last real attempt?
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '{state, last_auth_at, last_auth_result, last_auth_error}'

# 3. Where did the attempts die?
curl -sS -G "$BASE/connections/$CON_ID/auth-attempts?limit=10" -H "$AUTH" \
  | jq '.data[] | {outcome, stage, error_code, error_message, started_at}'

stage tells you which half of the problem you have:

stageMeaningWhose problem
initiatedrejected before any redirectulex's configuration
redirectedthe IdP would not accept the AuthnRequestthe customer's IdP
callbackthe Response arrived and was rejectedsignature, Destination, clock, replay
validatedthe assertion verified; now mapping to a userallow_create, join policy
provisionedJIT creation or linking faileddirectory data
mfawaiting on a second factorpolicy

#saml_signature_invalid

The most common SAML failure, and the one that appears suddenly, usually about a year in.

CauseTell
the IdP rotated its certificate and ulex has the old onecertificate parses passes but the signature does not verify — both certs parse, so only the signature can tell them apart
the IdP is signing with a different certificate than the one in its metadatayour metadata fetch and your connection disagree
the assertion is signed with an algorithm the connection does not allowsignature algorithm reports the algorithm, but ulex verifies whatever the IdP signed with — a mismatch shows up as saml_signature_invalid, not as a failed check

Diagnose

bash
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" | jq '.checks'
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq -r '.config.saml.x509_certificate' | head -1

Compare that certificate against the one in the customer's IdP admin console. If they differ, you have found it.

Fix

bash
curl -sS -X PATCH "$BASE/connections/$CON_ID" -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"config":{"strategy":"saml","saml":{ …the full current config, with the new "x509_certificate"… }}}' | jq -r .state
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" | jq -r .valid
curl -sS -X POST "$BASE/connections/$CON_ID/activate" -H "$AUTH" | jq -r .state

The connection is unusable between the patch and the activate. Ask the customer to serve both certificates during an overlap — Okta and Entra both support it, and it removes the window entirely.

Warning

PATCH /connections/{id} replaces the whole config object. It does not deep-merge. Read the current config, change the one field, send it all back. Sending a partial config.saml silently drops the other 25 fields and the connection stops validating.


#saml_response_invalid

CauseTell
the Response is not well-formed XMLcheck for a truncated base64 payload
Destination does not equal the ACS URLthe IdP is posting to a stale URL from before a migration
the NameID format is not the one the connection declaresthe customer changed their app's Name ID format

Diagnose

bash
# What does ulex believe the ACS URL is?
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '{acs: .config.saml.acs_url, allowed: .config.saml.acs_allowed_urls, format: .config.saml.name_id_format}'
bash
# What did the customer send? Decode it.
echo "$SAML_RESPONSE" | base64 -d | xmllint --format - | head -20
xml
<Response ID="_aH0mN…" Version="2.0" IssueInstant="2026-09-29T14:45:12Z"
         Destination="https://app.example.com/acs"
         InResponseTo="_4Kq9WmB2yLt7NxZ…">
  <Issuer>https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7</Issuer>

Destination here must equal the connection's ACS URL exactly. If the customer moved their app, they must update their IdP app; you cannot configure around it.


#saml_acs_mismatch

InResponseTo does not match an outstanding AuthnRequest, or the ACS URL is not in acs_allowed_urls.

SituationFix
IdP-initiated login with no InResponseToexpected and allowed. ulex handles unsolicited responses on /saml/sso
a genuine SP-initiated flow with a mismatched InResponseTothe customer is posting a stale response, usually after an SP migration
the ACS URL is not allowedadd it to acs_allowed_urls, max 20. Do not add a wildcard
ulex restarted between the AuthnRequest and the ACSthe outstanding-request table has a 5-minute TTL; a flow longer than that is not supported
bash
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml.acs_allowed_urls'

#saml_clock_skew

NotOnOrAfter is outside allowed_clock_skew_seconds (default 120, max 600).

json
{
  "error": {
    "code": "saml_clock_skew",
    "message": "The assertion NotOnOrAfter 2026-09-29T14:45:12Z is 4 minutes 12 seconds in the past. Allowed skew: 120s.",
    "retryable": false,
    "hint": "Synchronise the IdP's clock, or raise config.saml.allowed_clock_skew_seconds to at most 600."
  }
}

Diagnose. Four minutes of skew is a real NTP problem, not noise. Ask the customer to fix it.

If you must bridge it, raise the tolerance, and put a calendar reminder to lower it:

bash
curl -sS -X PATCH "$BASE/connections/$CON_ID" -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"config":{"strategy":"saml","saml":{ …, "allowed_clock_skew_seconds": 300 }}}'

600 seconds is a hard ceiling. A larger skew is an outage, not a tolerance problem.


#saml_replay_detected

The Assertion/@ID has already been consumed.

Two causes, one symptom:

CauseTell
a genuine IdP retry after a lost HTTP responsethe first attempt succeeded and created a session; the retry is redundant and safe to ignore
an actual replay attackthe same assertion is being posted twice, minutes or hours apart

Distinguish them by timing and by whether the first attempt succeeded:

bash
curl -sS -G "$BASE/connections/$CON_ID/auth-attempts?outcome=failure&limit=10" -H "$AUTH" \
  | jq '.data[] | {stage, error_code, started_at, duration_ms}'

An assertion is consumed exactly once. That is the whole defence; there is no tolerance setting, and there should not be.


#saml_nameid_mismatch

The NameID did not resolve to a user and the policy does not allow creating one.

ulex resolves in this order:

  1. external_id — from attribute_mapping.external_id, matched against user.external_id
  2. email — from attribute_mapping.email, matched against user.email
  3. a user already provisioned from the linked directory
  4. create, if allow_create: true
  5. fail
bash
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml | {name_id_transformations, allow_create, allow_update, allow_link}'
SymptomCauseFix
everyone fails on a new orgallow_create: false with no directoryturn it on, or provision via SCIM first
everyone fails after an email change upstreamstep 1 matched nothing and step 2 matched a different userpin external_id to a stable attribute
NameID is an opaque idname_id_transformations: "email" needs the IdP to release an email attributeask them to release email, or set "saml_subject_hash" and allow_link: true
it worked, then stoppeda certificate rotation dropped the connection to draftre-verify and re-activate

For a customer with SCIM, allow_create: false is correct. It turns "user not found" from a support ticket into a visible data-quality problem.


#Attribute mapping

The assertion verifies and the user is found, but the profile is wrong.

ProblemSymptomFix
Entra sends preferred_username, not emailaccess_denied or the wrong userattribute_mapping.email = "preferred_username"
groups are object idsthe groups attribute is full of GUIDsmap through your own lookup table, or group_name_template: "{name}" and slug them
active is the string "false"deactivated users can still log inactive_value: "false". ulex compares as a string, so this works
no groups attribute at allgroups is absent from the payloadthe IdP app is not configured to release it. group_attribute: "groups" does not make the IdP send it
department is a localised display nameyour role mapping silently matches nothingresolve it yourself against a table you control
external_id changes on re-importduplicate users on every syncpin it to a custom attribute, not id
bash
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml.attribute_mapping'

To see what the IdP actually sends, drive one login and read the attributes:

json
{ "name": "ulex_simulate_login", "arguments": {
  "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
  "email": "dana@globex.example",
  "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
  "protocol": "saml"
} }
json
{
  "outcome": "success",
  "name_id": "okta-00u1sAM2xY8ZQ4H1",
  "attributes": { "email": "dana@globex.example", "firstName": "Dana", "groups": ["engineering"], "userId": "00u1sAM2xY8ZQ4H1" }
}

#Reproducing a customer's IdP headlessly

You do not need their Okta to develop against.

bash
pnpm mock:up        # the fixture IdP on localhost:4001
json
{
  "name": "ulex_create_connection",
  "arguments": {
    "name": "Local fixture IdP",
    "config": {
      "strategy": "saml",
      "saml": {
        "entity_id": "http://localhost:4001/saml/metadata",
        "sso_url": "http://localhost:4001/saml/sso",
        "x509_certificate": "MIIE1DCCA3CgAwIBAgIULSJ…",
        "name_id_format": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
        "allow_create": true,
        "allow_link": true,
        "attribute_mapping": { "email": "email", "first_name": "firstName", "last_name": "lastName", "groups": "groups" }
      }
    }
  }
}

Six fixture users, each with a different failure mode — success, MFA, MFA failure, unknown user, replay, and an artificial delay for timeout tests. SAML API: headless SP-initiated testing.

And to get a real signed assertion without a browser:

json
{ "name": "ulex_simulate_login", "arguments": {
  "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
  "email": "dana@acme.example",
  "protocol": "saml",
  "return_assertion": true
} }

Feed assertion_b64 straight into your app's ACS handler in a test. It is a real, signed, correctly-timed assertion with real attributes.


#Checklist before you escalate to the customer

text
[ ] ulex_verify_connection returns valid: true
[ ] connection.state is "active"
[ ] connection.config.saml.x509_certificate matches what the IdP signs with
[ ] connection.config.saml.audience_uri matches what the IdP puts in Audience
[ ] the IdP app's ACS URL matches ulex's
[ ] the IdP app has "signed assertions" enabled
[ ] the IdP's Name ID format matches config.saml.name_id_format
[ ] the IdP's clock is NTP-synchronised
[ ] the IdP releases every attribute in config.saml.attribute_mapping
[ ] ulex_verify_connection passes expires_within_30_days

If all ten pass and the login still fails, it is ulex. Send us the request_id and the auth_attempt id, and quote Incident response for what we will do with them.

#Reference