Connect a SAML identity provider
Sign in an organisation through its SAML 2.0 identity provider. Built and tested locally; no real identity provider has been connected.
State in this release
Built and tested locally: sign-in started by your application, sign-in started by the identity provider (off by default), single logout, metadata import and refresh with an approval step, certificate pinning and rollover, key rotation for the service provider side, and a negative corpus of 46 attack and malformed-message vectors through the real assertion consumer. The console has screens for set-up, metadata, certificates and keys. The tests use a local signer: no real identity provider has been connected and interoperability with Keycloak, Entra, Okta or ADFS is unverified. Treat the first real connection as a pilot with a test user.
The feature is off until the operator sets AUTH_SERVICE_SAML_SP_ENABLED. While it is off the SAML routes answer 404 or a not-available page and the console refuses the saml strategy.
What the service accepts
The sign-in request goes to the identity provider by HTTP-Redirect, signed with the service's key by default, and the answer comes back by HTTP-POST to the assertion consumer URL.
- Only certificates you pinned are trusted. A signature by any other key is refused, and the signature must cover the Response or the Assertion.
- RSA of 2048 bits or more, or ECDSA, over SHA-256, SHA-384 or SHA-512. SHA-1, HMAC and DSA are refused.
- Encryption is optional. When on, the key travels with RSA-OAEP, the content cipher is AES-CBC or AES-GCM, and the identity provider must also sign the whole Response.
- An answer is accepted once: its state is consumed before any XML is read and the assertion id enters a replay cache. An answer with no matching request is refused unless IdP-initiated sign-in is on.
- At most 512 KiB of XML, and a uniform failure page that never says why.
Create the connection
Use the console's Add SAML connection, from a metadata URL, pasted XML or by hand, or post the strategy saml. Give the identity provider's entity id, its HTTP-Redirect sign-on URL, optionally a logout URL, and one to four signing certificates in PEM, or give its metadata and let the service fill the rest and pin the certificates. A metadata document must hold one entity; an aggregate is refused. The service sets its own base URL and refuses it in the settings. There is no client secret.
- name_id_format: persistent (default), emailAddress, unspecified or transient; transient needs subject_attribute.
- sign_authn_requests: default on. want_assertions_signed: default off. encrypt_assertions: default off. clock_skew_secs: 0 to 300, default 120.
- allow_idp_initiated: default off; see the section below.
Request · http
POST /v1/console/accounts/{account_id}/directories/{directory_id}/connections
Content-Type: application/json
X-Auth-Proof: <receipt, when the directory asks for one>
{
"strategy": "saml",
"display_name": "Acme SAML",
"config": {
"idp_entity_id": "https://idp.example.com/saml/metadata",
"sso_url": "https://idp.example.com/saml/sso",
"slo_url": "https://idp.example.com/saml/slo",
"name_id_format": "persistent"
},
"idp_certificates": [
"-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----"
],
"jit_enabled": true
}Register the service at the identity provider
Read the entity id, the assertion consumer URL, the logout URL and the metadata URL from the connection's SAML view. Most identity providers can import the service's metadata from its URL, published at /saml/sp/{connection_id}/metadata. Otherwise register the entity id, the assertion consumer URL with the HTTP-POST binding, the logout URL, the NameID format you chose, and send at least the email address as an attribute. The default mapping recognises the common attribute names of Microsoft, LDAP and plain email, mail, firstName, lastName, displayName and groups, then the NameID when its format is emailAddress.
How the person is identified
The identity is the identity provider's entity id plus the NameID value, prefixed by its format, or for transient the named attribute. Never an email address. Whether an address counts as verified is decided only by the connection being trusted for email and the address domain having a verified claim, never by anything in the assertion. A person is identified by the provider's issuer and a stable subject, never by an email address. An existing account is linked only when the provider verified the address, the connection is marked trusted for email, the domain has a verified claim on the connection and the person has no other federated identity. Otherwise nothing is attached on the provider's word: unless link_policy is never, the person proves they own the existing account with a code emailed to a verified address of it, a code from its authenticator app or one of its passkeys, and only then is the identity linked.
Enable and test
Enabling is refused until at least one identity provider certificate is active and the service's keys exist. The journey is: your application starts an authorization request, the person chooses Continue with the connection or types an address at a claimed domain, the browser goes to the start route, which parks the request and redirects to the identity provider, the identity provider posts the answer to the assertion consumer URL, and the person lands back at your authorization request with a hosted session whose method is federated. A rejected answer raises a saml.assertion.rejected event with a code only, capped at 30 a minute per connection, and never carries XML, a NameID or attacker text.
Sign-in started by the identity provider
Off by default. Turn on allow_idp_initiated and give an active application client of the directory and a login URI on the origin of one of its redirect URIs. An answer with no matching request is then read as unsolicited: the assertion must be at most 5 minutes old, and the identity provider's RelayState is ignored. The person is sent to your login URI with an iss parameter and starts their own authorization request; the answer itself issues no code. It is weaker than sign-in started by your application, so enable it only when the identity provider's launcher requires it.
Keeping it running
A metadata refresh never changes trust by itself. It leaves a diff of certificates added and removed and of endpoint or requirement changes, and a member with the manage role approves it with a fresh proof or rejects it. Old and new certificates both verify between the approval that adds one and the one that retires the other. Retiring or revoking a certificate takes a proof, and a revoked certificate can never be pinned again. Refreshes are limited to 12 an hour per connection.
Rotating the service's own keys is two proof-gated steps: publish a next key, give the identity provider the updated metadata, then promote it. Single logout from the identity provider ends this service's sessions for the person only on a signed, unreplayed LogoutRequest; sign-out through the service's end-session route ends the local session first and then sends a signed request to the identity provider. Disabling the connection ends every session it created.
What was not tested
A real identity provider of any kind, encrypted assertions from a real product, ADFS, metadata aggregates and unusual certificates from real products. The manual interoperability matrix is open. A test login with a decoded view of the assertion, a console mapping editor and assignment of applications to people are not built.