MCP Auth is here
Drop-in OAuth for your MCP Servers
Learn more
SSO
Jun 24, 2025

IDP vs SP initated SSO: How each flow works and when to use them

Hrishikesh Premkumar
Founding Architect

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.

SAML basics: IdPs, SPs, and assertions

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:

  • Service Provider (SP): The application requiring authentication, typically a web-based B2B SaaS product like Figma, GitLab, or a company’s internal reporting tool
  • Identity Provider (IdP): The system that owns and verifies user identities (e.g., Okta, Ping Identity)
  • SAML assertion: The payload sent from IdP to SP contains identity claims and session metadata

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.

SP initiated SSO 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.

SP initiated SSO flow

Flow steps:

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.

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_abc123" Version="2.0" IssueInstant="2024-06-01T12:00:00Z" Destination="https://idp.example.com/sso" AssertionConsumerServiceURL="https://sp.example.com/saml/acs"> <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">https://sp.example.com</saml:Issuer> <samlp:NameIDPolicy AllowCreate="true"/> </samlp:AuthnRequest>

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.

💡 Dev Note: The RelayState parameter helps SPs persist state across the SAML round trip, for example, redirecting the user to /dashboard or /billing/settings after login. The IdP must echo this value back unmodified.

Most SAML toolkits provide validation helpers. Example using passport-saml in Node.js:

samlStrategy.validatePostResponse({ SAMLResponse }, (err, profile) => { if (err) throw err; });

6. The Service Provider establishes a session and redirects the user to the appropriate authenticated area of the application.

Why SP initiated is the default for typical SaaS products:

  • Session control: The SP decides when sessions start or expire, giving apps full control over the auth flow
  • Correlated requests: Uses InResponseTo to match responses to specific AuthnRequests
  • Better observability: Easier to log and trace authentication steps for debugging and audits
  • Replay protection: Assertions can be strictly validated, reducing the risk of replay or injection

IdP initiated SSO flow

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.

IdP initiated SSO flow

Flow steps:

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.

💡 Dev note: Cache recently used AssertionIDs or SessionIndex values (for example, in Redis) and reject duplicates within a defined time window.

Why enterprises prefer IdP initiated for internal access:

  • Centralized access: Employees launch apps from a unified IdP portal like Okta or Azure AD
  • Simplified setup: Admins configure apps once on the IdP side, no per-user setup needed
  • Best for internal tools: Ideal for single-tenant, intranet, or internal dashboard use cases

How IdP and SP initiated SSO differ under the hood

Aspect
SP initiated
IdP initiated
Who starts the flow
Service Provider
Identity Provider
AuthnRequest sent?
Yes
No
Assertion linkage
InResponseTo and RelayState
None (unsolicited response)
Assertion delivery
POST to ACS URL via browser
POST to ACS URL via browser
SP validations
Full: Signature, Audience, Conditions, Response ID
Limited: Signature, Conditions
UX pattern
App-driven login
Dashboard/portal-driven launch
Risk profile
Lower (requests matched to responses)
Higher (requires defensive validation by SP)

How to secure IdP initiated SSO

IdP initiated SSO is valid under SAML, but because the SP never issued a request, the assertion must be validated with extra care.

Recommended security practices:

  • Short-lived assertions: Use NotBefore and NotOnOrAfter with minimal validity windows (e.g., 2–5 mins).
  • Trusted issuers only: Always validate the Issuer against your allowlist.
  • Replay protection: Track AssertionID or SessionIndex and reject duplicates.
  • Suspicious metadata check: Flag unsolicited assertions that include InResponseTo.
    Signature and audience:
    Verify both to ensure the assertion is valid and intended for your SP.

💡 Dev note: Unsolicited assertions are a common vector for man-in-the-middle misuse if left unchecked. If an unsolicited assertion includes an InResponseTo value, treat it as suspicious, as this often indicates an attempt to replay an earlier SP initiated response.

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.

When to use each flow

Use SP initiated when:

  • Precise session control: Initiation happens only when the app requires it
  • Strong validation: Enables checks like audience, InResponseTo, and RelayState mapping
  • Better auditability: Supports tracing login events across sessions and tenants

Use IdP initiated when:

  • Portal-first login: The user experience begins from an IdP dashboard like Okta or Google Workspace
  • Existing identity fit: Easier when integrating into IT-managed identity systems
  • Lightweight SP setup: The SP doesn’t need to initiate requests or track request state

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.

Supporting both with Scalekit

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.

How Scalekit simplifies the SAML layer:

  • SP AuthnRequest generation: Automatically generates and signs SAML AuthnRequests for SP-initiated flows.
  • IdP response validation: Validates unsolicited SAML Responses for IdP-initiated SSO, including replay protection.
  • Trust configuration: Manages per-IdP trust settings like certificates, issuer, ACS URL, and audience.
  • Login logging: Logs every SSO attempt for debugging, traceability, and compliance auditing.
  • User provisioning support: Supports SCIM-based provisioning and enriches user profiles after login.

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.

Conclusion

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.

FAQ

What’s the main difference between IdP and SP initiated SSO?

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.

Is IdP initiated SSO less secure?

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.

Can I support both flows in one app?

Yes. Most SAML libraries and platforms like Scalekit support dual-mode flows by validating inbound assertions and generating signed AuthnRequests based on tenant metadata.

Does OIDC support IdP initiated flows?

No. OIDC mandates SP initiated login via authorization requests. The flow is inherently request-bound, enforcing nonce and state verification to prevent unsolicited authentication.

What if an IdP sends a response I didn’t ask for?

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.

No items found.
On this page
Share this article
Add SSO for free

Acquire enterprise customers with zero upfront cost

Every feature unlocked. No hidden fees.
Start Free
$0
/ month
3 FREE SSO/SCIM connections
Built-in multi-tenancy and organizations
SAML, OIDC based SSO
SCIM provisioning for users, groups
Unlimited users
Unlimited social logins
SSO

IDP vs SP initated SSO: How each flow works and when to use them

Hrishikesh Premkumar

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.

SAML basics: IdPs, SPs, and assertions

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:

  • Service Provider (SP): The application requiring authentication, typically a web-based B2B SaaS product like Figma, GitLab, or a company’s internal reporting tool
  • Identity Provider (IdP): The system that owns and verifies user identities (e.g., Okta, Ping Identity)
  • SAML assertion: The payload sent from IdP to SP contains identity claims and session metadata

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.

SP initiated SSO 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.

SP initiated SSO flow

Flow steps:

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.

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_abc123" Version="2.0" IssueInstant="2024-06-01T12:00:00Z" Destination="https://idp.example.com/sso" AssertionConsumerServiceURL="https://sp.example.com/saml/acs"> <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">https://sp.example.com</saml:Issuer> <samlp:NameIDPolicy AllowCreate="true"/> </samlp:AuthnRequest>

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.

💡 Dev Note: The RelayState parameter helps SPs persist state across the SAML round trip, for example, redirecting the user to /dashboard or /billing/settings after login. The IdP must echo this value back unmodified.

Most SAML toolkits provide validation helpers. Example using passport-saml in Node.js:

samlStrategy.validatePostResponse({ SAMLResponse }, (err, profile) => { if (err) throw err; });

6. The Service Provider establishes a session and redirects the user to the appropriate authenticated area of the application.

Why SP initiated is the default for typical SaaS products:

  • Session control: The SP decides when sessions start or expire, giving apps full control over the auth flow
  • Correlated requests: Uses InResponseTo to match responses to specific AuthnRequests
  • Better observability: Easier to log and trace authentication steps for debugging and audits
  • Replay protection: Assertions can be strictly validated, reducing the risk of replay or injection

IdP initiated SSO flow

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.

IdP initiated SSO flow

Flow steps:

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.

💡 Dev note: Cache recently used AssertionIDs or SessionIndex values (for example, in Redis) and reject duplicates within a defined time window.

Why enterprises prefer IdP initiated for internal access:

  • Centralized access: Employees launch apps from a unified IdP portal like Okta or Azure AD
  • Simplified setup: Admins configure apps once on the IdP side, no per-user setup needed
  • Best for internal tools: Ideal for single-tenant, intranet, or internal dashboard use cases

How IdP and SP initiated SSO differ under the hood

Aspect
SP initiated
IdP initiated
Who starts the flow
Service Provider
Identity Provider
AuthnRequest sent?
Yes
No
Assertion linkage
InResponseTo and RelayState
None (unsolicited response)
Assertion delivery
POST to ACS URL via browser
POST to ACS URL via browser
SP validations
Full: Signature, Audience, Conditions, Response ID
Limited: Signature, Conditions
UX pattern
App-driven login
Dashboard/portal-driven launch
Risk profile
Lower (requests matched to responses)
Higher (requires defensive validation by SP)

How to secure IdP initiated SSO

IdP initiated SSO is valid under SAML, but because the SP never issued a request, the assertion must be validated with extra care.

Recommended security practices:

  • Short-lived assertions: Use NotBefore and NotOnOrAfter with minimal validity windows (e.g., 2–5 mins).
  • Trusted issuers only: Always validate the Issuer against your allowlist.
  • Replay protection: Track AssertionID or SessionIndex and reject duplicates.
  • Suspicious metadata check: Flag unsolicited assertions that include InResponseTo.
    Signature and audience:
    Verify both to ensure the assertion is valid and intended for your SP.

💡 Dev note: Unsolicited assertions are a common vector for man-in-the-middle misuse if left unchecked. If an unsolicited assertion includes an InResponseTo value, treat it as suspicious, as this often indicates an attempt to replay an earlier SP initiated response.

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.

When to use each flow

Use SP initiated when:

  • Precise session control: Initiation happens only when the app requires it
  • Strong validation: Enables checks like audience, InResponseTo, and RelayState mapping
  • Better auditability: Supports tracing login events across sessions and tenants

Use IdP initiated when:

  • Portal-first login: The user experience begins from an IdP dashboard like Okta or Google Workspace
  • Existing identity fit: Easier when integrating into IT-managed identity systems
  • Lightweight SP setup: The SP doesn’t need to initiate requests or track request state

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.

Supporting both with Scalekit

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.

How Scalekit simplifies the SAML layer:

  • SP AuthnRequest generation: Automatically generates and signs SAML AuthnRequests for SP-initiated flows.
  • IdP response validation: Validates unsolicited SAML Responses for IdP-initiated SSO, including replay protection.
  • Trust configuration: Manages per-IdP trust settings like certificates, issuer, ACS URL, and audience.
  • Login logging: Logs every SSO attempt for debugging, traceability, and compliance auditing.
  • User provisioning support: Supports SCIM-based provisioning and enriches user profiles after login.

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.

Conclusion

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.

FAQ

What’s the main difference between IdP and SP initiated SSO?

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.

Is IdP initiated SSO less secure?

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.

Can I support both flows in one app?

Yes. Most SAML libraries and platforms like Scalekit support dual-mode flows by validating inbound assertions and generating signed AuthnRequests based on tenant metadata.

Does OIDC support IdP initiated flows?

No. OIDC mandates SP initiated login via authorization requests. The flow is inherently request-bound, enforcing nonce and state verification to prevent unsolicited authentication.

What if an IdP sends a response I didn’t ask for?

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.

No items found.
Ship Enterprise Auth in days