API

SAML 2.0

ulex as a SAML 2.0 identity provider: SP metadata, SP-initiated login, the Assertion Consumer Service, IdP-initiated SSO, Single Logout, signature and clock-skew validation, attribute mapping, and certificate rotation.

ulex acts as a SAML 2.0 identity provider to your applications and as a SAML 2.0 service provider to a customer's enterprise IdP. Both directions live on a saml connection.

Required scopes: read:connections for metadata and login URLs, saml:consume for ACS and SLO.

DirectionYou configureulex is
Your app federates into ulexa saml connection pointing at your app's SPIdP
ulex federates into a customer's IdPa saml connection pointing at Okta/Entra/ADFSSP

#Endpoints

EndpointMethodCredentialPurpose
/applications/{id}/metadataGETnoneulex's IdP metadata, for your app to consume
/applications/{id}/secretGETread:applicationsthe SP signing certificate, for your app to verify assertions
/connections/{id}/saml/metadataGETnonethe customer's IdP metadata, for ulex to consume
/connections/{id}/saml/loginGETnoneSP-initiated; 302 to the customer IdP
/connections/{id}/saml/acsPOSTsaml:consumeulex's ACS: where the customer IdP posts the Response
/connections/{id}/saml/sloGET, POSTsaml:consumesingle logout both ways
/connections/{id}/saml/ssoPOSTnoneIdP-initiated; used by the built-in fixture IdP

#ulex as IdP — SP metadata

bash
curl -sS "$BASE/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata"
xml
<?xml version="1.0" encoding="UTF-8"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B">
  <IDPSSODescriptor WantAuthnRequestsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
    <KeyDescriptor use="signing">
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:X509Data>
          <ds:X509Certificate>MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAMMAmVyb2xf…</ds:X509Certificate>
        </ds:X509Data>
      </ds:KeyInfo>
    </KeyDescriptor>
    <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</NameIDFormat>
    <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso"/>
    <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso"/>
    <SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/slo"/>
    <AttributeConsumingService index="1">
      <ServiceName xml:lang="en">Acme Support</ServiceName>
      <ServiceDescription xml:lang="en">ulex SAML service provider</ServiceDescription>
      <RequestedAttribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="1"/>
      <RequestedAttribute Name="firstName" isRequired="0"/>
      <RequestedAttribute Name="lastName" isRequired="0"/>
      <RequestedAttribute Name="displayName" isRequired="0"/>
      <RequestedAttribute Name="title" isRequired="0"/>
      <RequestedAttribute Name="department" isRequired="0"/>
      <RequestedAttribute Name="groups" isRequired="0"/>
    </AttributeConsumingService>
  </IDPSSODescriptor>
</EntityDescriptor>

Entity id, SSO URL, and SLO URL for a given application:

PropertyValue
entityIDhttps://ulexid.com/api/v1/applications/{applicationId}
SSO URL (Redirect)https://ulexid.com/api/v1/auth/{applicationId}/sso
SSO URL (POST)same
SLO URLhttps://ulexid.com/api/v1/auth/{applicationId}/slo
Warning

Use the metadata document, not a hand-typed entity id. Hand-typed entity ids fail on the trailing character often enough to be worth avoiding entirely.

Assertion signing certificate:

bash
curl -sS "$BASE/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/secret" -H "Authorization: Bearer $ULEX_API_KEY"
json
{
  "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
  "saml_signing_certificate": "-----BEGIN CERTIFICATE-----\nMIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3D…\n-----END CERTIFICATE-----",
  "saml_signing_certificate_expires_at": "2027-03-11T00:00:00.000Z",
  "saml_signing_kid": "key_01M3PSVJA0YP2WDPM2RDR15MGH"
}

#ulex as IdP — SP-initiated login into your app

bash
curl -sS -L "$BASE/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso?RelayState=st_9Kq2WmB7yLt4NxZ&login_hint=dana%40acme.example"

The response is a signed <samlp:Response> on the HTTP-POST binding, posted to your app's ACS:

xml
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                ID="_8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mN"
                Version="2.0" IssueInstant="2026-09-29T14:45:12Z"
                Destination="https://app.example.com/saml/acs"
                InResponseTo="_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8">
  <saml:Issuer>https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B</saml:Issuer>
  <samlp:Status><samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></samlp:Status>
  <saml:Assertion ID="_aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3t"
                  Version="2.0" IssueInstant="2026-09-29T14:45:12Z">
    <saml:Issuer>https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B</saml:Issuer>
    <saml:Subject>
      <saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">usr_01M3PSV9GRT8GQGEG686AR1W9S</saml:NameID>
      <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <saml:SubjectConfirmationData NotOnOrAfter="2026-09-29T14:45:17Z" Recipient="https://app.example.com/saml/acs"/>
      </saml:SubjectConfirmation>
    </saml:Subject>
    <saml:Conditions NotBefore="2026-09-29T14:45:07Z" NotOnOrAfter="2026-09-29T14:45:17Z">
      <saml:AudienceRestriction>
        <saml:Audience>https://app.example.com/saml/metadata</saml:Audience>
      </saml:AudienceRestriction>
    </saml:Conditions>
    <saml:AuthnStatement AuthnInstant="2026-09-29T14:45:12Z" SessionIndex="_s1x8Kq2WmB4yLt7">
      <saml:AuthnContext>
        <saml:AuthnContextClassRef>urn:ulex:acr:mfa</saml:AuthnContextClassRef>
      </saml:AuthnContext>
    </saml:AuthnStatement>
    <saml:AttributeStatement>
      <saml:Attribute Name="email"><saml:AttributeValue>dana@acme.example</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="firstName"><saml:AttributeValue>Dana</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="lastName"><saml:AttributeValue>Okafor</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="displayName"><saml:AttributeValue>Dana Okafor</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="title"><saml:AttributeValue>Support Lead</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="department"><saml:AttributeValue>Customer Success</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="groups"><saml:AttributeValue>engineering</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="org_id"><saml:AttributeValue>org_01M3PSV8HGTKQFCAYF9GDWGN3C</saml:AttributeValue></saml:Attribute>
      <saml:Attribute Name="org_role"><saml:AttributeValue>owner</saml:AttributeValue></saml:Attribute>
    </saml:AttributeStatement>
  </saml:Assertion>
</samlp:Response>

Validation rules ulex guarantees, and that your app should also enforce:

CheckValue
Destinationequals your ACS URL exactly
InResponseTomatches the AuthnRequest you sent
Issuerequals the metadata entityID
Audienceequals your SP entity id
NotBefore / NotOnOrAfter5-minute window, 120 s clock-skew tolerance
Assertion signatureRSA-SHA256 over the assertion, with the certificate from /secret
NameIDpersistent; the ulex usr_… id. It does not change when the user's email does
Replayeach Assertion/@ID is consumed once
Warning

Configure the assertion lifetime to at least 5 minutes on your side, and make sure your clock is synchronised. ulex issues a 5-minute window; a consumer that rejects a 1-minute window will fail intermittently in a way that looks like flakiness.

#Headless SP-initiated testing

No browser needed:

json
{ "name": "ulex_simulate_login", "arguments": {
  "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
  "email": "dana@acme.example",
  "protocol": "saml",
  "return_assertion": true
} }
json
{
  "session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
  "outcome": "success",
  "protocol": "saml",
  "in_response_to": "_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8",
  "name_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "attributes": {
    "email": "dana@acme.example",
    "firstName": "Dana",
    "lastName": "Okafor",
    "displayName": "Dana Okafor",
    "title": "Support Lead",
    "department": "Customer Success",
    "groups": ["engineering"]
  },
  "assertion_b64": "PHNhbWw6UmVzcG9uc2UgeG1sbnM6c2FtbHA6UmVzcG9uc2U…",
  "not_on_or_after": "2026-09-29T14:45:17.000Z"
}

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

#ulex as SP — connecting to a customer's IdP

bash
curl -sS -X POST "$BASE/connections" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "name": "Globex SAML",
    "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
    "config": {
      "strategy": "saml",
      "saml": {
        "entity_id": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7",
        "sso_url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml",
        "slo_url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/slo/saml",
        "x509_certificate": "MIIE1DCCA3CgAwIBAgIULSJ…",
        "name_id_format": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
        "binding": "saml_redirect",
        "want_response_signed": true,
        "want_assertion_signed": true,
        "want_authn_request_signed": false,
        "signature_algorithm": "rsa-sha256",
        "signature_validation": "strict",
        "allowed_clock_skew_seconds": 120,
        "name_id_transformations": "email",
        "allow_create": true,
        "allow_update": true,
        "allow_link": true,
        "group_attribute": "groups",
        "groups_attribute": "groups",
        "active_attribute": "active",
        "active_value": "true",
        "attribute_mapping": {
          "email": "email",
          "first_name": "firstName",
          "last_name": "lastName",
          "display_name": "displayName",
          "job_title": "title",
          "department": "department",
          "external_id": "userId",
          "groups": "groups"
        }
      }
    }
  }'
json
{
  "id": "con_01M3PSVY108K5TEHHQ82WN30YK",
  "object": "connection",
  "name": "Globex SAML",
  "state": "draft",
  "config": { "strategy": "saml", "saml": { "entity_id": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7", "binding": "saml_redirect", "signature_validation": "strict", "allowed_clock_skew_seconds": 120 } },
  "last_auth_at": null,
  "last_auth_result": null
}

Validate before activating:

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/verify" -H "Authorization: Bearer $ULEX_API_KEY"
json
{
  "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
  "valid": true,
  "checks": [
    { "check": "entity_id present", "status": "passed", "detail": "https://acme.okta.com/app/exkxxxx/sso/saml/metadata" },
    { "check": "sso_url present", "status": "passed", "detail": "https://acme.okta.com/app/exkxxxx/sso/saml" },
    { "check": "certificate parses", "status": "passed", "detail": "pinned certificate yields a usable public key" },
    { "check": "signature algorithm", "status": "passed", "detail": "rsa-sha256 — ulex verifies the algorithm the IdP names, it does not choose it" },
    { "check": "clock skew budget", "status": "passed", "detail": "120s" },
    { "check": "sso_url reachable", "status": "passed", "detail": "HTTP 200" }
  ]
}

certificate parses is the one worth reading. ulex asks whether the pinned value actually yields a public key, because a field that is present is not the same as a field that is usable — a certificate the verifier cannot read passes an emptiness check and then fails every single sign-in, with nothing in ulex's logs to explain it.

Always 200, even when a check fails: read valid and checks[].

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/activate" -H "Authorization: Bearer $ULEX_API_KEY"

#Attribute mapping that actually works

ProblemSymptomFix
email is preferred_username (Entra)400 access_denied, user not foundattribute_mapping.email = "preferred_username"
NameID is an opaque idcannot link to an existing username_id_transformations: "email" requires the IdP to release an email attribute; otherwise "saml_subject_hash" and set allow_link: true
Groups are object idsgroups claim is full of GUIDsmap through a lookup table in your app, or set group_name_template and let ulex slug them
active is "false" string, not booleandeactivated users can still log inactive_value: "false", active_attribute: "active" — ulex compares as a string
Assertion is not signedsaml_signature_invalidwant_assertion_signed: true on the IdP app
Clock skewsaml_clock_skewfix the IdP's NTP; only then raise allowed_clock_skew_seconds, max 600

#ACS and SLO

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/acs" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "SAMLResponse=$(cat response.b64)" \
  --data-urlencode "RelayState=st_9Kq2WmB7yLt4NxZ"
json
{
  "session_id": "ses_01M3PSW6T8FT4M24DH9P8YAY32",
  "user_id": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
  "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
  "outcome": "success",
  "strategy": "saml",
  "amr": ["saml"],
  "relay_state": "st_9Kq2WmB7yLt4NxZ",
  "acs_redirect": "https://app.example.com/auth/callback?code=ac_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8&state=st_9Kq2WmB7yLt4NxZ"
}

Every ACS post performs, in order:

  1. XML parse with external entities and DTDs disabled;
  2. Destination equals the connection's ACS URL and is in acs_allowed_urls;
  3. InResponseTo matches an outstanding AuthnRequest, unless the request was IdP-initiated;
  4. Issuer equals config.saml.entity_id;
  5. signature verifies against config.saml.x509_certificate, with signature_algorithm and digest_algorithm enforced;
  6. Conditions time window against allowed_clock_skew_seconds;
  7. NameID transforms to a user via name_id_transformations, honouring allow_link, allow_create, allow_update;
  8. attributes map through attribute_mapping; groups sync through group_attribute;
  9. Assertion/@ID is recorded for replay detection;
  10. a session is created and InResponseTo is marked consumed.
bash
curl -sS "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/slo" \
  -H "Authorization: Bearer $ULEX_API_KEY" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "SAMLRequest=$(cat logout_request.b64)"

SLO terminates the ulex session, revokes the refresh-token family, and returns a signed LogoutResponse. IdP-initiated logout is POST /saml/slo from the IdP with a LogoutRequest.

#IdP-initiated SSO

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/sso" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "SAMLResponse=$(cat assertion.b64)"

IdP-initiated responses have no InResponseTo. ulex accepts them only when the connection's IdP is trusted and RelayState is either absent or resolves to a registered redirect. It returns a session and an acs_redirect your app can follow, or nothing at all — IdP-initiated login cannot be replayed into a different application.

#Certificate rotation

Customer IdPs rotate certificates roughly yearly, and Entra does it without warning.

  1. Download the new certificate from the IdP. ulex does not parse certificate expiry dates, so there is no check that warns you in advance — the certificate is only ever used as a public key, and a key does not expire.
  2. PATCH /connections/{id} with the new config.saml.x509_certificate. The connection drops to state: "draft".
  3. POST /connections/{id}/verify → confirm valid: true and that certificate parses passed.
  4. POST /connections/{id}/activate.
  5. GET /audit-events?action=connection.updated&connection_id={id} to confirm.

The connection is unusable between steps 2 and 4. Schedule this in a maintenance window.

#Errors

codeStatusCause → fix
saml_request_invalid400malformed AuthnRequest, or a SAMLRequest that is not correctly deflated and base64-encoded
saml_response_invalid400malformed Response, or Destination mismatch
saml_signature_invalid400signature does not verify → re-upload the certificate, then verify
saml_nameid_mismatch400NameID resolves to nothing and allow_link: false → set allow_link: true or name_id_transformations: "email"
saml_acs_mismatch400InResponseTo unknown, or the ACS URL is not in acs_allowed_urls
saml_replay_detected400this assertion id was already consumed. The IdP retried; the first one succeeded
saml_clock_skew400outside allowed_clock_skew_seconds → fix NTP, or raise the tolerance to at most 600
invalid_state_transition409activate with an expired certificate or unverified domains
connection_not_active403forgot POST /connections/{id}/activate

#MCP equivalents

ulex_get_saml_sp_metadata, ulex_get_saml_idp_metadata, ulex_get_saml_login_url, ulex_create_connection, ulex_activate_connection, ulex_verify_connection.

Deeper: SAML SP integration, SAML metadata reference, SAML troubleshooting.