SAML 2.0 Master Study Notes & Enterprise Architecture Guide
Comprehensive engineering documentation covering XML assertions, bindings, canonicalization (C14N), digital signatures (XMLDSig), SubjectConfirmation, Single Logout (SLO), and Microsoft Entra ID enterprise app integration.
1. SAML 2.0 Architectural Foundations
Security Assertion Markup Language (SAML) 2.0 OASIS standard overview and trust model.
Principal (End User)
The human user agent operating a web browser. The user authenticates against the Identity Provider without revealing raw corporate credentials (passwords, MFA secrets) to the Service Provider.
Service Provider (SP)
The business application relying on SAML assertions (e.g., saml.ntmscloud.in, Salesforce, ServiceNow). The SP verifies incoming cryptographic assertions and establishes local application sessions.
Identity Provider (IdP)
The centralized authentication authority (Microsoft Entra ID, Okta, PingFederate). The IdP maintains user directories, evaluates Conditional Access and MFA, and signs SAML assertions using private X.509 keys.
🔑 How Trust is Established (The Metadata Exchange):
Before any user can sign in, the SP and IdP establish mutual trust out-of-band by exchanging SAML Metadata XML documents (<md:EntityDescriptor>). The SP registers its Entity ID and ACS URL in Entra ID, while downloading the IdP's public X.509 Signing Certificate (NTMS-APP-SAML.cer) to verify future signed assertions.
2. Anatomy of SAML XML Documents
Detailed structural breakdown of AuthnRequest, SAMLResponse, and Assertion elements.
A. <samlp:AuthnRequest> (SP → IdP)
HTTP-RedirectInResponseTo to prevent replay.B. <saml:Assertion> (IdP → SP)
HTTP-POSTNotBefore / NotOnOrAfter) and audience whitelist.3. SAML 2.0 Protocol Bindings Explained
How SAML protocol messages are packaged and transported over standard HTTP.
GET with Query Parameters
Message is deflated with RFC 1951 Deflate compression, Base64-encoded, and URL-encoded as query parameter ?SAMLRequest=....
⚠️ Best for AuthnRequest. Limited to ~2KB URL limits in older browsers/proxies.
Form POST with Body Payload
Message is directly Base64-encoded (NO Deflate!) and placed inside a hidden HTML input field <input type="hidden" name="SAMLResponse">.
✅ Standard for SAMLResponse. Can handle multi-kilobyte signed XML assertions with groups.
2-Step Back-Channel Resolution
The IdP passes only a small opaque token (SAMLart) via the browser. The SP contacts the IdP directly via back-channel SOAP to exchange the artifact for the actual assertion.
🛡️ Highest privacy: Browser never observes the raw assertion. Requires direct SP-to-IdP network route.
4. XML Digital Signatures (XMLDSig) & Canonicalization (C14N)
Understanding why XML signatures differ fundamentally from JSON Web Signatures (JWS).
Why XML Needs Canonicalization (C14N)
In XML, two documents can be semantically identical while having completely different byte streams (differing whitespace, newline conventions, attribute ordering, namespace prefixes).
Canonicalization Method (C14N): Converts XML into a standardized canonical byte representation prior to computing SHA-256 digests. Standard SAML uses http://www.w3.org/2001/10/xml-exc-c14n# (Exclusive Canonicalization).
Enveloped vs Response Signatures
In SAML, a signature can sign:
- The Full <samlp:Response> element: Protects the outer status and response structure.
- The Inner <saml:Assertion> element (Enveloped): Protects identity claims even if extracted and forwarded.
- Both Elements: Highly recommended for enterprise defense against XML Signature Wrapping (XSW).
Microsoft Entra ID signs both the Assertion and the Response depending on Enterprise App configuration settings.
5. Subject Identification & NameID Formats
Choosing the appropriate user identifier format in Microsoft Entra ID.
| NameID Format URI | Example Value | Use Case / Behavior |
|---|---|---|
| urn:...:nameid-format:emailAddress | sanjay.dubey@outlook.com | Standard corporate email. User-friendly; vulnerable to re-assignment if employee departs and new user takes email. |
| urn:...:nameid-format:persistent | G-9842a-194fa-91b... | Pairwise pseudonym string permanently assigned to the user for this specific SP. Protects privacy across disparate vendors. |
| urn:...:nameid-format:transient | T-48194-e81a-... | Temporary random session string discarded upon logout. Best for anonymous survey portals or temporary access. |
| urn:...:nameid-format:unspecified | NTMS\sdubey | Domain-qualified username or custom corporate employee identifier. Default fallback in many legacy on-prem systems. |
6. Microsoft Entra ID Enterprise App Integration Playbook
Exact step-by-step Azure Portal settings for production SAML 2.0 deployment.
Basic SAML Configuration Parameters
Strictly matches the <saml:Issuer> of AuthnRequest and AudienceRestriction.
Endpoint where Microsoft Entra ID HTTP-POSTs the SAMLResponse.
Where users land when launching the app from Office 365 or My Apps portal.
Signing Certificate & Claim Rules
Downloaded as NTMS-APP-SAML.cer. Valid for 3 years. Pinned locally on the SP.
Set to Sign SAML response and assertion using SHA-256 (deprecating legacy SHA-1).
Map user.userprincipalname → Unique User Identifier, and emit App Roles as roles claim for RBAC.