skip to content

SAML

The XML standard behind enterprise SSO: signed assertions, IdP and SP roles, POST and Redirect bindings, and metadata trust. B2B integrations still arrive as SAML, so interviewers still ask.

part ofFederated identityoverview, primer and where to startread it →
on this pageshow

questions

page 1 of 2

Why does the SAML HTTP-POST binding show the user a page that submits itself, and what is on that form?

level: juniorimportance: must knowfreq 52%

answer

  1. browsers cannot POST on their own
  2. a page whose only job is submitting
  3. hidden control, name fixed by the binding
  4. base64 of the XML, no compression
  5. SAMLResponse plus an optional RelayState

basics

~20 s

A browser will not originate a cross-site POST on its own, so the sender returns a page holding a form aimed at the recipient's endpoint and submits it by script. The form carries the base64-encoded SAML message in a hidden control named SAMLRequest or SAMLResponse.

solid answer

~40 s

The HTTP-POST binding, `urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`, has to get a message from one server to another through a browser that only follows redirects and submits forms. Since there is no way to ask a browser to POST somewhere by itself, the sender returns an ordinary page whose form `action` is the recipient's endpoint, `method` is POST, and whose hidden control is named exactly `SAMLRequest` or `SAMLResponse` with the base64-encoded XML as its value. An optional second hidden control named `RelayState` may ride along, capped at 80 bytes by the binding. A script submits the form on load, and a `noscript` button lets the user do it manually. The flash of a near-empty page is that form being posted.

code

xml · 6 lines
xml
<form method="POST" action="https://register.example/sso/acs">
  <input type="hidden" name="SAMLResponse"
         value="PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6..."/>
  <input type="hidden" name="RelayState" value="drw-4417-rev14"/>
  <noscript><input type="submit" value="Continue"/></noscript>
</form>

go deeper

for a junior

Recall the shape: a page arrives, a hidden field named SAMLRequest or SAMLResponse holds base64 XML, and a script posts the form to the other party's endpoint. That is the whole mechanism.

for a middle

Explain why the binding exists at all — a browser will not originate a cross-site POST — and name what the binding fixes: the control names, the base64 encoding with no compression, and the optional 80-byte RelayState control.

for a senior

Show you can debug it from the wire: a mistyped control name, a GET where a POST was expected, base64 whitespace that one binding tolerates and the other forbids, and a resubmitted form arriving twice.

for a principal

The judgment call is which binding each message direction uses across a set of partners, and what you standardise on when their length limits and encoders differ. Uniformity is worth more here than per-partner optimisation.

## What a binding is, and what this one has to solve A SAML **binding** is the rule for putting a SAML protocol message onto a concrete transport. It is neither the message nor the profile. The **Web Browser SSO profile**, `urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser`, says which messages flow between which parties; a binding says how each one physically travels. That profile has an awkward constraint at its centre: the two servers exchanging messages frequently have no direct connection to each other, so every message rides in the user's browser. A browser is a cooperative courier with exactly two habits a server can rely on. It follows a redirect by itself, and it submits a form. What it will never do is originate a cross-site POST unprompted. The HTTP-POST binding, `urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`, is built on the second habit: to make the browser POST a message to the recipient's endpoint, the sender returns an ordinary HTML page containing a form aimed at that endpoint plus a small script that submits it on load. The blank flash the user sees — often captioned "please wait" — is that page. ## What is actually on the page - The form's `action` is the recipient's endpoint URL and its `method` is `POST`. - One hidden control is named **exactly** `SAMLRequest` when a request is being sent, or `SAMLResponse` when a response is. These names are fixed by the binding; they are not a local convention, and they are case-sensitive. - That control's value is the **base64 encoding (RFC 2045) of the XML message**. No compression is applied — this is the single largest mechanical difference from the Redirect binding. - If the sender is carrying state through the round trip, a second hidden control named `RelayState` holds it. At the binding level its value must not exceed **80 bytes**; what it means and who is allowed to trust it is a different subject entirely. - A `noscript` submit button, so the exchange still completes where scripting is off. The browser then sends an ordinary `application/x-www-form-urlencoded` POST body containing those same parameter names. ## POST against Redirect, on the points that matter here | | HTTP-POST | HTTP-Redirect | |---|---|---| | Encoding of the message | base64 of the XML | DEFLATE, then base64, then URL-encoding | | Where the message sits | a form control in a POST body | a query-string parameter | | Practical length budget | effectively none | whatever the shortest intermediary allows | | How a signature travels | enveloped inside the XML, untouched by the binding | detached, as separate `SigAlg` and `Signature` query parameters | | What the user sees | a page that submits itself | a redirect, with no visible page | ## Why a response almost always arrives this way A `<Response>` carrying a signed assertion is a large document, and the parts that make it large — a signature value, an embedded certificate — are high-entropy, so they barely compress. After encoding, such a message essentially precludes the Redirect binding on length grounds alone, which is why the binding specification prefers POST where a message contains signed content. There is a second, quieter reason. On this binding the sender does not have to do anything about signing at all: an enveloped XML signature sits inside the XML and is carried inside the base64 blob unchanged, so the binding neither knows nor cares that it is there. The Redirect binding cannot do that and must define a separate, detached signature over the query string instead. ## What goes wrong, and how it looks 1. **A mistyped control name.** `samlResponse`, `SAML_Response` or `saml-response` do not exist. The recipient sees a POST with no SAML parameter in it and rejects the whole request as malformed, which reads to an operator like "the identity provider sent nothing". 2. **The wrong binding aimed at the endpoint.** If the endpoint receives a GET whose query string carries `SAMLResponse`, the sender used HTTP-Redirect against an endpoint that expects HTTP-POST. Nothing about the message is wrong; the transport is. 3. **Base64 line breaks.** RFC 2045 base64 permits line breaks, and most POST-side parsers tolerate them. On the Redirect binding whitespace must be removed, so a sender that reuses one encoder for both bindings can work on one and fail on the other. 4. **The back button and resubmission.** Because the page really did submit a form, going back can prompt the user to resubmit it, and the recipient may then receive the same message twice. Deciding what to do with a repeat is the receiving implementation's problem, not the binding's. The habit worth forming is to read the exchange as bytes: which parameter name, which encoding, which HTTP method. Almost every binding-level failure is visible in exactly those three facts.

  • What happens if the hidden control is named samlResponse instead of SAMLResponse?
    The recipient looks for `SAMLRequest` or `SAMLResponse` and finds neither, so it sees a POST with no SAML message in it and rejects the request. The names are fixed by the binding and case-sensitive; there is no fallback matching.
  • Why does this binding not compress the message the way HTTP-Redirect does?
    Compression exists on the Redirect binding to fight a URL length ceiling. A POST body has no comparable practical limit, so compressing would buy nothing but processing cost and one more place for two implementations to disagree.
  • What does the user see if scripting is disabled in the browser?
    The page stops at the form instead of submitting it, and the `noscript` button — conventionally labelled something like "Continue" — lets the user post it manually. The exchange still completes; it simply needs one click.

saying these in an interview costs you the question

  • Says the POST binding compresses the message like Redirect does
  • Thinks the hidden control can be named whatever the sender likes
  • Believes base64 in the form hides the message from the user
  • Calls the self-submitting page an implementation quirk rather than the binding
  • Treats a GET carrying SAMLResponse as the same binding
open as a page

In SAML 2.0 web single sign-on, which party issues a SAML assertion and which party acts on it?

level: juniorimportance: must knowfreq 62%

basics

~10 s

The identity provider authenticates the person and issues a signed SAML assertion; the service provider receives it at its AssertionConsumerService endpoint and must validate it before creating its own application session.

open as a page

In SAML 2.0 web single sign-on, what makes a login SP-initiated rather than IdP-initiated?

level: juniorimportance: must knowfreq 50%

basics

~20 s

SP-initiated login starts at the service provider, which sends the browser to the identity provider carrying an AuthnRequest message. IdP-initiated login starts at the identity provider, which sends an unsolicited Response the service provider never asked for.

open as a page

What does `<AudienceRestriction>` constrain in a SAML assertion, and what does a missing one allow?

level: middleimportance: must knowfreq 52%

basics

~20 s

AudienceRestriction names, by entityID URI, the parties the assertion is addressed to; anyone not named must not rely on it. With none present, every service provider that receives a copy can read it as addressed to itself, and nothing in the document contradicts that.

open as a page

In a SAML assertion, what does the `<Conditions>` `NotOnOrAfter` bound that `<SubjectConfirmationData>` `NotOnOrAfter` does not?

level: middleimportance: must knowfreq 58%

basics

~20 s

The Conditions NotOnOrAfter bounds how long the assertion is a valid statement at all; the SubjectConfirmationData NotOnOrAfter bounds only how long this bearer may present it for delivery. They are two separate clocks and both must hold.

open as a page

What encodings does the SAML HTTP-Redirect binding apply to a message, and why does the result still overflow URLs?

level: middleimportance: must knowfreq 46%

basics

~20 s

The message is DEFLATE-compressed, then base64-encoded, then URL-encoded into a SAMLRequest or SAMLResponse query parameter. Base64 adds about a third back and percent-encoding adds more, so anything carrying a signature and a certificate barely compresses and overflows.

open as a page

In a SAML `<LogoutRequest>`, what does a `SessionIndex` child add that the `<NameID>` alone does not?

level: middleimportance: must knowfreq 57%

basics

~20 s

The identifier names the principal; SessionIndex names one particular session that recipient holds for them. Without it a recipient cannot tell which of a person's several live sessions to end, so it must end all of them or guess.

open as a page

In SAML 2.0, what does a party's `<EntityDescriptor>` metadata document declare, and what does exchanging it establish?

level: middleimportance: must knowfreq 55%

basics

~20 s

A SAML EntityDescriptor names one party by its entityID and declares, per role, the endpoints it exposes, the public keys it signs with or is encrypted to, and the NameID formats it supports. Two exchanged documents are the trust relationship.

open as a page

In a SAML metadata document, what do `validUntil` and `cacheDuration` each tell the party consuming it?

level: middleimportance: must knowfreq 50%

basics

~20 s

validUntil is an absolute instant after which the element and its contents must not be used at all. cacheDuration is a relative ceiling on how long a consumer may keep a copy before refetching. They answer different questions and a root element needs at least one.

open as a page

In a signed SAML 2.0 assertion, what does the single <ds:Reference> inside <ds:SignedInfo> actually cover?

level: middleimportance: must knowfreq 48%

basics

~20 s

It covers exactly one element: the ds:Reference carries a same-document URI of the form #id naming that element's ID attribute, and the DigestValue beside it is the hash of that element and its descendants after the listed transforms have run.

open as a page

In a SAML 2.0 Response message, what does the InResponseTo attribute prove, and what must a service provider compare it against?

level: middleimportance: must knowfreq 58%

basics

~20 s

InResponseTo carries the ID of the AuthnRequest a response answers. The service provider must compare it against a request ID it generated and is still awaiting, and reject any response whose value it cannot find.

open as a page

At a health research data-access portal, a posted SAMLResponse verifies cleanly yet admits a cohort nobody approved — how does XML signature wrapping achieve that?

level: seniorimportance: must knowfreq 55%

basics

~20 s

The genuine signed assertion is moved elsewhere in the XML tree and a forged copy is put in its place. Verification resolves the reference by ID and re-checks the moved original, while the application reads the element sitting in the expected position.

open as a page

What are the main parts of a SAML 2.0 assertion, and which part names the person it describes?

level: juniorimportance: should knowfreq 42%

basics

~20 s

A SAML 2.0 assertion holds an Issuer naming who made the statement, a Subject naming who it is about, Conditions bounding when it may be relied on, and statements — an AuthnStatement and often an AttributeStatement — saying what it claims.

open as a page

Why does SAML 2.0 define a Single Logout profile instead of leaving each service provider to drop its own session?

level: juniorimportance: should knowfreq 46%

basics

~20 s

One federated login creates one session at the identity provider, acting as session authority, plus one at each service provider. Dropping only the local session leaves the others live, so the Single Logout profile propagates the exit to every participant.

open as a page

In a SAML 2.0 <samlp:Response>, what does a <saml:EncryptedAssertion> protect that the TLS connection to the service provider does not?

level: juniorimportance: should knowfreq 34%

basics

~20 s

A saml:EncryptedAssertion holds the assertion as ciphertext the identity provider encrypted to the service provider's public encryption key, so the browser relaying the document, its history, its logs and any intermediary see no plaintext subject or attributes.

open as a page

In a SAML assertion's `<AttributeStatement>`, what do an `<Attribute>`'s `Name` and `NameFormat` tell the service provider?

level: middleimportance: should knowfreq 38%

basics

~20 s

Name identifies which attribute is being asserted and NameFormat says how to read that name — as a URI from an agreed namespace, for example — while the asserted values sit in one or more AttributeValue children of the same element.

open as a page

In SAML 2.0, what does a party's entityID identify, and what does it not?

level: middleimportance: should knowfreq 44%

basics

~20 s

entityID is the unique name of a SAML party — an identity provider, a service provider or an attribute authority. It names an organisation or deployment, never a person, and although it is written as a URI it is compared as a string, not fetched.

open as a page

What does a SAML `<LogoutResponse>` whose second-level `<StatusCode>` is `PartialLogout` tell the initiator?

level: middleimportance: should knowfreq 41%

basics

~20 s

The exchange itself worked, the outcome did not: the session authority ended what it could, and at least one session participant never confirmed. The top-level code stays Success, so a caller reading only that level reports a clean logout it did not get.

open as a page

Under Web Browser SSO with the HTTP POST binding, why is a signature over only the <samlp:Response> not enough?

level: middleimportance: should knowfreq 38%

basics

~20 s

The Web Browser SSO profile requires the assertions themselves to be signed when the HTTP POST binding is used. A response-level signature is a statement about one envelope: it does not travel with an assertion and does not stand alone.

open as a page

In SAML 2.0, what does a service provider give up by accepting unsolicited IdP-initiated responses?

level: middleimportance: should knowfreq 44%

basics

~20 s

An unsolicited Response carries no InResponseTo, so there is no stored request to match it against. It gives up correlation between answer and request, the state filed with that request, and any ability to refuse a login it never started.

open as a page

A SAML assertion's `<AuthnStatement>` carries AuthnInstant and SessionNotOnOrAfter — what has the identity provider stated, and what has it not?

level: seniorimportance: should knowfreq 33%

basics

~20 s

AuthnInstant states when the subject authenticated to the identity provider, which may be hours before this assertion was issued; SessionNotOnOrAfter bounds the session with that identity provider. Neither says the subject was present at the moment the statement was made.

open as a page

On the SAML HTTP-Redirect binding, which octets do SigAlg and Signature cover, and why does re-encoding the parsed message break verification?

level: seniorimportance: should knowfreq 35%

basics

~10 s

They cover a query string built in the fixed order SAMLRequest=value&RelayState=value&SigAlg=value, with the values URL-encoded exactly as sent. Neither DEFLATE nor percent-encoding is canonical, so a rebuilt string is different octets and fails.

open as a page

A SAML identity provider is asked to post an assertion to an AssertionConsumerServiceURL it has never registered — what should it do, and why?

level: seniorimportance: should knowfreq 38%

basics

~20 s

It should refuse to deliver there. The Web Browser SSO profile obliges the asserting party to establish that the delivery location really is controlled by the service provider it is asserting about, and honouring an unregistered location hands a valid signed assertion to whoever nominated it.

open as a page

In SAML Single Logout, why can the SOAP back channel fail to end a session a front-channel chain would end?

level: seniorimportance: should knowfreq 34%

basics

~20 s

A SOAP logout is a server-to-server call and can only delete state the participant holds server-side. A participant whose session exists solely as a cookie in the user agent has nothing to delete, so only a front-channel hop through the browser can end it.

open as a page

In a SAML role descriptor, what does the `use` attribute on a `<KeyDescriptor>` select, and what does omitting it mean?

level: seniorimportance: should knowfreq 38%

basics

~20 s

The use attribute is drawn from md:KeyTypes and takes the values signing or encryption, saying which purpose that published key serves. It is optional, and when omitted the key may be used for both. A role may publish several key descriptors.

open as a page

In SAML metadata, what do `WantAuthnRequestsSigned`, `AuthnRequestsSigned` and `WantAssertionsSigned` declare — and what are they not?

level: seniorimportance: should knowfreq 30%

basics

~20 s

They are optional boolean declarations: the identity-provider role's WantAuthnRequestsSigned asks for signed requests, while the service-provider role's AuthnRequestsSigned says it signs its own and WantAssertionsSigned asks for signed assertions. They state expectations; they enforce nothing.

open as a page

A SAML service provider redirects to whatever RelayState comes back with the response — what is the defect?

level: seniorimportance: should knowfreq 38%

basics

~20 s

RelayState is opaque data echoed back through the browser, not a trusted destination. A service provider that redirects to it unvalidated turns its own assertion-consumer endpoint into an open redirect to any address an attacker supplies.

open as a page

With SAML metadata as your only lever, how do you move a signing key across several hundred counterparties you cannot compel?

level: principalimportance: should knowfreq 22%

basics

~20 s

Publish the incoming key as a second KeyDescriptor while the outgoing one is still live, wait out the cacheDuration in the copies counterparties already hold, then switch and later withdraw the old one. The clock is set by the old duration, not the new.

open as a page

What does the SAMLart value in the SAML HTTP-Artifact binding contain, and how is the real message fetched?

level: middleimportance: nice to knowfreq 22%

basics

~20 s

SAMLart carries a short base64 reference, not the message: a TypeCode, an EndpointIndex, a 20-byte SourceID and a 20-byte MessageHandle. The recipient redeems it by sending ArtifactResolve to the issuer over a back channel and receiving ArtifactResponse.

open as a page

In a SAML AuthnRequest, what do ForceAuthn and IsPassive each ask the identity provider to do?

level: middleimportance: nice to knowfreq 28%

basics

~10 s

ForceAuthn="true" asks the identity provider to authenticate the person afresh instead of relying on an existing session. IsPassive="true" asks it to answer without taking visible control of the user interface.

open as a page

showing 1–30 of 32