When someone clicks “Login with SSO,” the authentication can begin from either side: the application (called the Service Provider, or SP) can trigger the login, or the user might start from a centralized identity system (the Identity Provider, or IdP), like Okta or Azure AD.
This architecture-level choice shapes how login requests are constructed, how assertions are validated, and how much control the app has over session state and correlation. IdP-initiated flows are often easier to configure, especially in IT-managed environments, but they come with validation tradeoffs. SP-initiated flows provide stronger replay protection and tighter session control but need coordination between systems.
To understand how these flows are structured and how they affect session control, we’ll discuss the roles of the Service Provider (SP) and Identity Provider (IdP) in the following section.
This blog breaks down both flows from a developer perspective, how each is structured in SAML, what risks to account for, and how Scalekit lets you support both without building custom logic for every tenant.
Security Assertion Markup Language (SAML) 2.0 is a commonly accepted protocol to achieve federated authentication. It can enable distinct systems to securely share authentication and authorization information through signed XML records, generally through experiencing browser redirects and POSTs.
The three key components in a SAML authentication flow are:
Each SAML authentication entails redirecting the browser to the IdP and finally posting a signed assertion to the SP. The organization of such messages, the form of their safety verification depends on the initiator of the flow.
In an SP initiated SSO flow, the authentication begins when the user lands on your application directly. This is common for B2B SaaS products.
1. User accesses the Service Provider directly, such as logging into a B2B SaaS app like Notion, Salesforce, or an internal dashboard at dashboard.company.com.
2. SP generates a SAML AuthnRequest (including requestID and RelayState) and redirects the user to the Identity Provider using HTTP-Redirect or HTTP-POST binding.
3. IdP authenticates the user, typically via credentials, MFA, or an existing SSO session.
4. IdP issues a signed SAML response and posts it to the SP’s Assertion Consumer Service (ACS) endpoint via HTTP POST binding.
5. SP validates the response by checking InResponseTo, RelayState, signature, audience, and other assertion conditions. The SP also ensures that the RelayState value is echoed back unmodified by the IdP.
Most SAML toolkits provide validation helpers. Example using passport-saml in Node.js:
6. The Service Provider establishes a session and redirects the user to the appropriate authenticated area of the application.
In an IdP initiated flow, the user begins at their Identity Provider dashboard, like Okta, Azure AD, or Google Workspace, where users see a list of company-approved applications, click the application tile and get redirected with a pre-constructed SAML Response.
1. User logs into the IdP portal, such as Okta, Azure AD, or Google Workspace.
2. User selects the target application by clicking the app tile assigned to the Service Provider, such as an internal dashboard, HR tool, or reporting system.
3. IdP generates a signed SAML assertion and posts it directly to the Service Provider's (SP) Assertion Consumer Service (ACS) endpoint using HTTP POST binding, without including a requestID.
4. SP validates the SAML response by checking fields like InResponseTo (if present), RelayState, signature, issuer, audience, timestamps, and other conditions.
5. Since there is no InResponseTo in IdP-initiated flows, the SP must rely on AssertionID or SessionIndex for replay protection.
6. SP establishes a session and redirects the user to the authenticated area of the application.
Why enterprises prefer IdP initiated for internal access:
IdP initiated SSO is valid under SAML, but because the SP never issued a request, the assertion must be validated with extra care.
You should also implement replay detection using the AssertionID or SessionIndex. Store these temporarily (e.g., in Redis) and reject duplicates within a time window.
Set short validity windows using NotBefore and NotOnOrAfter ideally no more than a few minutes.
In most real-world integrations, you’ll need to support both.
IdP initiated SSO is typical in environments with centralized dashboards, such as portals like portal.university.edu for students, or intranet.corp.com for employees accessing HR systems, CRMs, and dashboards. SP initiated flows are more common in SaaS platforms where users land directly from bookmarked links (e.g., app.vendor.com/login), SaaS invitations (like from Asana or HubSpot), or deep links in alerting tools like PagerDuty or Jira, and where tight correlation and auditing are required.
Scalekit gives developers one interface to support both SP initiated and IdP initiated SAML flows without managing SAML request signing, assertion parsing, or validation logic manually. It also simplifies IdP onboarding by managing metadata exchange through XML uploads or metadata URLs, including automatic certificate and endpoint refreshing.
With Scalekit, you can ship enterprise-ready SAML support in hours,not weeks, and avoid edge-case implementation errors that would otherwise block customer onboarding.
For advanced use cases, Scalekit supports dynamic IdP metadata ingestion and allows fine-grained validation rules for incoming assertions. Webhook support for login events can be layered externally using your app’s event system.
SP initiated and IdP initiated SSO flows differ not just in where the login begins, but in how trust is established, how assertions are validated, and how much control the SP has over the session lifecycle. SP initiated flows offer tighter correlation and better replay protection, while IdP initiated flows simplify user experience from identity portals but require defensive validation by the SP. Most modern SAML implementations must support both to meet enterprise expectations.
Scalekit abstracts the protocol-level complexity in both cases, generating signed AuthnRequests, validating unsolicited responses, and managing IdP metadata dynamically. To explore implementation details, visit the SAML implementation guide or test flows in the interactive IdP simulator.
SP initiated SSO starts with an AuthnRequest from the service provider, enabling request-response correlation via InResponseTo. IdP initiated SSO bypasses this and delivers unsolicited assertions, trading control for convenience.
Yes, it lacks a correlated request (RequestID), increasing susceptibility to replay and assertion injection attacks. Strong assertion lifetime checks, signature validation, and replay detection are essential.
Yes. Most SAML libraries and platforms like Scalekit support dual-mode flows by validating inbound assertions and generating signed AuthnRequests based on tenant metadata.
No. OIDC mandates SP initiated login via authorization requests. The flow is inherently request-bound, enforcing nonce and state verification to prevent unsolicited authentication.
That’s an unsolicited SAML assertion. Treat with strict validation check signature, issuer, audience, and timestamps. Reject any response with a mismatched or reused InResponseTo.