SAML — signed assertions and four namespaces¶
This is the XML you log in with. Every "Sign in with Okta / Entra ID / Ping" button at work is, underneath, a SAML exchange: an identity provider mints a signed XML document saying who you are, and an application trusts it. SAML 2.0 is an OASIS standard from 2005 that never left — enterprise single sign-on standardized on it, and REST never displaced it there.
It belongs right after XML Signature because that page is SAML's trust model: an assertion is worthless unless its signature verifies, and it is detached from its issuer and re-parsed by a stranger — exactly the case canonicalization exists for. SAML also splits its work across four namespaces, one per layer, which makes it a clean final lesson in the ownership pattern.
The assertion¶
The heart of SAML is the Assertion: a statement, made by an issuer, about a
subject, valid for a window.
Issueris who minted the statement — the identity provider (IdP). The receiver will trust this assertion only if it is signed by the key it has on file for this issuer (see Metadata below).Subject/NameIDis who the assertion is about. TheFormatsays how to read the value — here, an email address.SubjectConfirmationwith method bearer means "whoever presents this is the subject" — soRecipientpins the one application allowed to receive it. Present the same assertion to a different app and it is invalid.Conditionsbound validity: a few-minute window (NotBefore/NotOnOrAfter) and anAudienceRestrictionnaming the intended service provider (SP). Between them, a leaked assertion is useless at another SP or a minute later.AuthnStatementrecords how and when the user authenticated — theAuthnContextClassRefURN distinguishes a password over TLS from MFA, a hardware token, and so on.AttributeStatementcarries the claims the SP actually consumes — email, group membership (note the multi-valuedgroups), department, whatever was agreed. This is the payload; everything above is envelope and trust.
The response that carries it¶
In the everyday browser-SSO flow, the assertion travels inside a
samlp:Response — and here the second namespace appears.
- The protocol namespace
samlp:owns the request/response machinery;saml:owns the assertion inside it. Two namespaces, two jobs:InResponseToties this back to the SP's originalAuthnRequest, andDestinationmust match the SP's assertion-consumer URL — both anti-forgery checks the SP makes before it ever looks at the claims. samlp:Statusis the protocol-level outcome;…:status:Successhere. A failed login carries a different status URN and no assertion.
This part is not SOAP
Unlike SOAP, the dominant Web Browser SSO profile uses no
SOAP at all — the IdP base64-encodes this Response into a hidden field and
has the browser auto-POST it to the SP. SOAP only shows up in SAML's
back-channels: Artifact Resolution and the WS-Trust security token service.
SAML is XML-as-document, not XML-as-RPC.
The signature¶
That assertion is only trustworthy because it is signed. A ds:Signature —
the exact XML-DSig vocabulary from the previous page — sits
enveloped inside the Assertion (or the Response, or both):
<saml:Assertion ID="_a1b2c3d4" …>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:Reference URI="#_a1b2c3d4">…</ds:Reference> <!-- (1)! -->
</ds:SignedInfo>
<ds:SignatureValue>MC0CFFrV…==</ds:SignatureValue>
</ds:Signature>
<saml:Issuer>…</saml:Issuer>
…
</saml:Assertion>
Reference URI="#_a1b2c3d4"signs the assertion by itsID— not the whole document — so the signed assertion stays valid when the SP lifts it out of theResponse. And the algorithm is Exclusive C14N, for exactly the reason the XML-DSig page warned about: the assertion is detached from the IdP's document and re-embedded in the SP's, so only the namespaces it uses may travel with it. Inclusive C14N here is the classic SAML interop bug.
Metadata: the contract¶
How does the SP know which key signs the IdP's assertions, and where to send
users to log in? The two parties exchange metadata — a md:EntityDescriptor
that is, in effect, WSDL
for identity: a machine-readable description of endpoints, certificates, and
supported bindings.
entityIDis the stable name both sides use for this IdP — the same string that appears as the assertion'sIssuer. That is the link: the SP matchesIssueragainst theentityIDwhose metadata it trusts.- The signing certificate. This is the whole point — the SP verifies every assertion against this key. Hand-waving the metadata exchange is hand-waving the trust.
SingleSignOnServicepublishes where and over which binding to start a login. An SP's metadata mirrors this withAssertionConsumerServiceendpoints.
The four namespaces¶
SAML is a clean example of one document, four vocabularies, each owning a layer:
| Prefix | Namespace URI | Owns |
|---|---|---|
saml |
urn:oasis:names:tc:SAML:2.0:assertion |
the claims: subject, conditions, attributes |
samlp |
urn:oasis:names:tc:SAML:2.0:protocol |
the request/response envelope and status |
ds |
http://www.w3.org/2000/09/xmldsig# |
the signature (XML-DSig) |
md |
urn:oasis:names:tc:SAML:2.0:metadata |
the published contract: endpoints, certs, bindings |
Encrypted assertions add a fifth, xenc (…/xmlenc#), but the four above are
the ones you meet in every flow.
Things to note¶
- The assertion / protocol split (
saml:vssamlp:) is deliberate: the same signed assertion can ride in a browser-POSTResponse, an artifact, or a SOAP back-channel. Separating the claims from the message that carries them is a namespace decision. - Trust rests entirely on XML-DSig. A SAML assertion is only as good as its signature — and because the SP lifts it out of one document and into another, Exclusive C14N is not optional trivia here, it is the difference between working and not.
- Metadata is the contract — identity's answer to WSDL:
entityID, signing certs, endpoints, and bindings, exchanged out of band so two organizations can trust each other's XML. - The
Conditionsand bearerRecipientare what make it safe to hand a token to the user's own browser: audience, expiry, and recipient together pin a stolen assertion to one SP and a few minutes.
Next: GPX and KML — back to friendlier ground, with two geospatial vocabularies and two different ways of allowing extensions.