Appearance
SAML Basics
112. What is Security Assertion Markup Language (SAML), and what problem does it solve?
The short answer
SAML 2.0 is an XML-based standard, from 2005, that lets an identity provider tell a separate web application, the service provider, that a user has logged in, along with facts about them, in a digitally signed message called an assertion. It solved web single sign-on across different companies' domains: an employee logs in once at their company's IdP and gets into Salesforce, Workday or a partner portal without separate passwords. It is still the most widely supported enterprise SSO protocol.
The problem before SAML. Browsers will not share cookies between acme.example and salesforce.com. So a company had no standard way to say to an outside app, "this person is our employee, already logged in". Every app needed its own password. SAML gave both sides a common, signed message format and a set of ways to pass it through the user's browser.
113. Explain the main components in SAML architecture?
The short answer
SAML has four building blocks. Assertions are the signed XML statements about the user. Protocols are the request and response messages, such as AuthnRequest, Response and LogoutRequest. Bindings are how those messages travel over HTTP, such as HTTP Redirect or HTTP POST. Profiles combine the other three for a use case; the Web Browser SSO profile is the one everyone means by "SAML login". The parties are the user, the identity provider and the service provider, which trust each other through exchanged metadata and certificates.
| Part | Example |
|---|---|
| Identity provider (IdP) | Microsoft Entra ID, Okta, ADFS |
| Service provider (SP) | Salesforce, your SaaS app |
| Assertion | "This is asha@acme.example, authenticated with MFA at 10:02" |
| Protocol message | AuthnRequest from SP, Response from IdP |
| Binding | HTTP Redirect for the request, HTTP POST for the response |
| Metadata | XML describing each side's endpoints and certificates |
114. What is a SAML assertion?
The short answer
A SAML assertion is an XML document, signed by the identity provider, that makes statements about a user: who they are, when and how they authenticated, and attributes such as email, name and groups. It also states who it is for, the SP's entity ID, and a short validity window. The SP trusts the statements only after checking the signature with the IdP's certificate and checking those conditions. It plays the same role as an ID token in OIDC.
xml
<saml:Assertion ID="_a75adf55" IssueInstant="2026-10-27T10:02:00Z" Version="2.0">
<saml:Issuer>https://sts.acme.example/</saml:Issuer>
<ds:Signature>…</ds:Signature>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">asha@acme.example</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData InResponseTo="_req7781" NotOnOrAfter="2026-10-27T10:07:00Z"
Recipient="https://app.example/saml/acs"/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2026-10-27T10:01:30Z" NotOnOrAfter="2026-10-27T10:07:00Z">
<saml:AudienceRestriction><saml:Audience>https://app.example/saml</saml:Audience></saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2026-10-27T10:02:00Z" SessionIndex="_s91">
<saml:AuthnContext><saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef></saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute Name="email"><saml:AttributeValue>asha@acme.example</saml:AttributeValue></saml:Attribute>
<saml:Attribute Name="groups"><saml:AttributeValue>finance</saml:AttributeValue></saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>Reading it like the SP does: who issued it (Issuer), proof it was not changed (Signature), who it is about (NameID), which request it answers (InResponseTo), where it may be delivered (Recipient), when it is valid (NotBefore, NotOnOrAfter), who may use it (Audience), how the user logged in (AuthnStatement), and facts about them (AttributeStatement).
115. What are the parts of a SAML assertion?
The short answer
An assertion has: an ID and IssueInstant; the Issuer, the IdP's entity ID; a Signature over the assertion; the Subject, with a NameID identifying the user and SubjectConfirmation data saying where and until when it may be presented; Conditions, a validity window and an AudienceRestriction naming the intended SP; and one or more statements: authentication, attribute, and rarely authorization decision. Every part except the statements exists to stop the assertion being forged, reused or sent to the wrong app.
| Part | Purpose | SP must check |
|---|---|---|
ID | Unique identifier | Not seen before, to stop replay |
Issuer | Which IdP | Equals the configured IdP entity ID |
Signature | Integrity and origin | Valid with the IdP's certificate, covering this assertion |
Subject / NameID | Who the user is | Use as the identity |
SubjectConfirmationData | Recipient, NotOnOrAfter, InResponseTo | Matches our ACS URL, not expired, answers our request |
Conditions | Validity window and Audience | Within the window; audience is our entity ID |
| Statements | Authentication and attributes | Read only after all checks above pass |
116. What are the Subject, Attribute, Authentication, and Authorization statements in SAML?
The short answer
The Subject identifies who all the statements are about, using a NameID. An authentication statement says the subject logged in at a certain time, by a certain method such as password or MFA, and gives a SessionIndex for logout. An attribute statement lists facts about the subject, such as email, department and group membership. An authorization decision statement says whether the subject may perform an action on a resource; it is defined in the standard but rarely used, because apps make their own authorization decisions.
| Element | Answers | Example |
|---|---|---|
| Subject | About whom? | NameID asha@acme.example |
| Authentication statement | Logged in when and how? | AuthnInstant 10:02, method MFA |
| Attribute statement | What do we know about them? | email, department=Finance, groups=finance |
| Authorization decision statement | May they do X on Y? | Rare; apps decide this themselves |
NameID formats matter. emailAddress is readable but changes when the email changes. persistent is an opaque, stable ID per SP, the SAML equivalent of OIDC's sub. Prefer persistent, or a stable attribute such as the directory's immutable object ID, as the key you link accounts by.
117. What is a SAML artifact?
The short answer
A SAML artifact is a short reference number sent through the browser instead of the assertion itself. The SP receives the artifact, then calls the IdP's artifact resolution service directly, server to server, over SOAP with mutual authentication, to fetch the real assertion. This keeps the assertion out of the browser entirely, which helps when it is large or confidential. It is the same idea as OAuth's authorization code. It is rarely used today, because it needs a direct back-channel connection between the SP and the IdP.
| HTTP POST binding | HTTP Artifact binding | |
|---|---|---|
| Browser carries | The whole signed assertion | A short reference |
| Extra call | None | SP calls the IdP's artifact service |
| Assertion visible to the user's browser | Yes | No |
| Needs SP to reach IdP directly | No | Yes |
| Usage today | Very common | Rare |
118. What is the Assertion Consumer Service (ACS) URL?
The short answer
The ACS URL is the endpoint on the service provider that receives the SAML response from the IdP, for example https://app.example/saml/acs. The IdP sends the response there, usually by making the browser auto-submit a form POST. The SP registers its ACS URL with the IdP in advance, and the IdP must only send responses to registered URLs. The SP must check that the assertion's Recipient and the response's Destination equal its own ACS URL, so an assertion meant for another app cannot be replayed to it.
What the IdP sends to the browser to deliver the response:
html
<form method="post" action="https://app.example/saml/acs">
<input type="hidden" name="SAMLResponse" value="PHNhbWxwOlJlc3BvbnNlIC4uLg==" />
<input type="hidden" name="RelayState" value="/reports/q3" />
</form>
<script>document.forms[0].submit()</script>Reading it: SAMLResponse is the Base64-encoded XML response. RelayState carries the page the user originally wanted, so the SP can send them there after login. Validate RelayState as a local path, or it becomes an open redirect.
The ACS endpoint and SameSite. This is a cross-site POST from the IdP's domain. A SameSite=Lax or Strict cookie set before login is not sent with it. So the SP must not depend on a pre-login cookie arriving at the ACS, or it must set that cookie with SameSite=None; Secure. This is a common cause of "SAML works in one browser but not another" (SameSite values).
119. What is SAML metadata XML, and what information does it contain?
The short answer
Metadata is an XML document each side publishes to describe itself, so they can be configured to trust each other without typing details by hand. It contains the entity ID, the unique name of the IdP or SP; the endpoints, such as the IdP's SSO and logout URLs or the SP's ACS URL, each with its binding; the certificates used for signing and encryption; the supported NameID formats; and contact and organisation details. Often it is exchanged as a URL that each side fetches, so certificate changes are picked up automatically.
xml
<EntityDescriptor entityID="https://sts.acme.example/" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
<IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<KeyDescriptor use="signing">
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><X509Data><X509Certificate>MIIC8D…</X509Certificate></X509Data></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://sts.acme.example/saml2"/>
<SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://sts.acme.example/saml2/logout"/>
</IDPSSODescriptor>
</EntityDescriptor>| Element | Meaning |
|---|---|
entityID | The IdP's unique name; must match Issuer in assertions |
KeyDescriptor use="signing" | The certificate whose key signs assertions |
SingleSignOnService | Where the SP sends login requests |
SingleLogoutService | Where to send logout messages |
SP metadata AssertionConsumerService | The SP's ACS URL |
120. What are SAML bindings?
The short answer
A binding defines how a SAML message is carried inside HTTP. HTTP Redirect puts a compressed, Base64-encoded message in a URL query parameter; it suits short messages such as an AuthnRequest. HTTP POST puts the Base64-encoded message in a hidden form field that the browser auto-submits; it suits large signed responses. HTTP Artifact sends only a reference and fetches the message over a back channel. SOAP is used for direct server-to-server calls, such as artifact resolution and some logout flows.
| Binding | Message travels in | Size limit | Typical use |
|---|---|---|---|
| HTTP Redirect | URL query, ?SAMLRequest=… | URL length, a few KB | AuthnRequest, LogoutRequest |
| HTTP POST | Auto-submitted form body | Large | Response with the assertion |
| HTTP Artifact | A reference, resolved by SOAP | Not applicable | Hiding the assertion from the browser |
| SOAP | Direct HTTP between servers | Large | Artifact resolution, back-channel logout |
121. What is the difference between HTTP Redirect and HTTP POST bindings?
The short answer
With HTTP Redirect, the message is DEFLATE-compressed, Base64-encoded and put in the URL as SAMLRequest or SAMLResponse, and any signature is sent as separate SigAlg and Signature URL parameters. It is limited by URL length, so it is used for small requests. With HTTP POST, the message is Base64-encoded, not compressed, into a hidden form field and submitted by the browser, and any signature is embedded inside the XML. It handles large signed assertions, so responses almost always use POST.
| HTTP Redirect | HTTP POST | |
|---|---|---|
| Carried in | URL query string | Form body |
| Encoding | DEFLATE, then Base64, then URL-encode | Base64 |
| Signature | Separate URL parameters | Inside the XML |
| Size | Small, about 2 KB to 8 KB | Large |
| Appears in logs and history | Yes | No |
| Typical message | AuthnRequest | Response |
Why signatures differ. URL-based messages can be re-encoded by browsers and proxies, which would break an XML signature inside them. So the Redirect binding signs the exact query string bytes instead.
122. What is the difference between IdP-initiated and SP-initiated SAML login?
The short answer
In SP-initiated login, the user starts at the app. The app sends an AuthnRequest to the IdP, the user logs in, and the IdP posts back a response that references that request with InResponseTo. In IdP-initiated login, the user starts at the IdP's portal, such as the Microsoft My Apps page, clicks an app tile, and the IdP sends an unsolicited response to the app's ACS URL with no request behind it. Both deliver the same kind of assertion, but IdP-initiated loses the link to a specific request.
123. Which SAML initiation flow is generally preferable, and why?
The short answer
SP-initiated is preferable. The SP can tie the response to a request it made from this browser, by checking InResponseTo, and that closes off replay and login CSRF attacks, where an attacker forces a victim's browser to log in as the attacker. It also returns the user to the page they wanted through RelayState, and works when users go straight to a bookmark. IdP-initiated is convenient for portal tiles, but it should be accepted only with strict checks, or turned into SP-initiated by having the tile link to the app's own login URL.
The safe way to support portal tiles. Configure the IdP tile to open https://app.example/saml/login instead of posting an assertion directly. The app then starts a normal SP-initiated login. The user sees the same one-click experience, and the app keeps the InResponseTo check.
If you must accept IdP-initiated responses:
- Keep the assertion lifetime very short, a few minutes.
- Store every assertion
IDuntil it expires, and reject repeats. - Never use
RelayStatefrom an unsolicited response as a redirect without checking it. - Allow it per customer, only when they need it.