SAML Authentication Flow
You'll learn: How SAML enables single sign-on through SP-initiated and IdP-initiated authentication flows with different assertion delivery methods.
Understanding SAML Flows
SAML authentication can begin in two ways, depending on who starts the process. Think of it like entering a building: you might approach security first (SP-initiated), or security might escort you from the entrance (IdP-initiated).
SP-Initiated Flow
The Service Provider-initiated flow starts when you try accessing a protected resource:
- User requests a resource from the Service Provider (SP)
- SP generates an
AuthnRequestand redirects the user to the Identity Provider (IdP) - IdP authenticates the user (login page)
- IdP generates a SAML assertion and sends it back to the SP
- SP validates the assertion and grants access
This is like showing up at a venue and being directed to check-in first.
IdP-Initiated Flow
The Identity Provider-initiated flow starts at the IdP portal:
- User logs into the IdP portal directly
- User selects an application to access
- IdP generates a SAML assertion without receiving a request
- IdP sends the assertion directly to the SP
- SP validates and grants access
This is like checking in at a hotel desk, then being escorted to your room without asking.
Assertion Bindings
SAML uses two primary methods to exchange assertions:
HTTP Redirect Binding: The assertion is encoded in the URL query string (Base64 + URL-encoded). Limited by URL length but doesn't require JavaScript.
HTTP POST Binding: The assertion is sent via an auto-submitted HTML form in the response body. Supports larger payloads and is more commonly used for responses.
Both flows protect against tampering through XML signatures embedded in the assertion.
Key Takeaway: SAML flows can be SP-initiated (user starts at the app) or IdP-initiated (user starts at the login portal), with assertions delivered via HTTP Redirect or POST bindings to complete secure single sign-on.