What Happens Behind the Scenes of a Single Sign-On (SSO) Login?

When you click "Sign in with your company account", the application redirects your browser to an identity provider (IdP) such as Microsoft Entra ID, Okta or Google. The IdP checks whether you already have a session; if not, it asks for your password and MFA. It then sends your browser back to the application with a one-time authorisation code (OpenID Connect) or a signed assertion (SAML).

Jul 15, 2025 - 15:08
Updated: 
101.6k

Active Directory & Identity Security in Cybersecurity & Ethical Hacking · Explainer

What Happens Behind the Scenes of a Single Sign-On (SSO) Login?

Quick answer: When you click "Sign in with your company account", the application redirects your browser to an identity provider (IdP) such as Microsoft Entra ID, Okta or Google. The IdP checks whether you already have a session; if not, it asks for your password and MFA. It then sends your browser back to the application with a one-time authorisation code (OpenID Connect) or a signed assertion (SAML). The application exchanges the code for an ID token, verifies the signature, issuer, audience, expiry and nonce, and creates its own session. Because the IdP remembers you, the next application signs you in without asking again.

Key takeaways

  • The application never sees your password; only the IdP does.
  • OpenID Connect uses tokens (JSON); SAML uses signed XML assertions.
  • PKCE and state or nonce values stop interception and replay.
  • Applications must validate tokens fully, not just decode them.
  • One strong login protects many apps, but a compromised IdP session affects all of them.

Table of Contents

Who Is Involved in an SSO Login?

RoleOIDC nameSAML name
You and your browserUser agentUser agent
The app you wantRelying party (client)Service provider
The login serviceOpenID providerIdentity provider

What Happens Step by Step With OpenID Connect?

  1. You open the app. It creates random state, nonce and a PKCE code verifier (RFC 7636), and redirects your browser to the IdP's authorise endpoint.
  2. The IdP checks for an existing session cookie. If none, it shows its own login page, then MFA.
  3. The IdP may apply conditional access: device compliance, location, risk.
  4. The IdP redirects back to the app's registered redirect URI with a short-lived code and the same state.
  5. The app checks state, then calls the IdP's token endpoint server to server with the code and PKCE verifier.
  6. The IdP returns an ID token, and usually an access token and refresh token.
  7. The app validates the ID token and creates its own session cookie for you.
GET https://login.example-idp.com/authorize?
  response_type=code
  &client_id=crm-app
  &redirect_uri=https://crm.example.com/callback
  &scope=openid%20profile%20email
  &state=af0ifjsldkj
  &nonce=n-0S6_WzA2Mj
  &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
  &code_challenge_method=S256

This is the authorisation code flow defined in OpenID Connect Core, with PKCE as RFC 9700 recommends for all clients.

What Is Inside an ID Token?

An ID token is a signed JWT. Decoded, its payload looks like this:

{
  "iss": "https://login.example-idp.com",
  "aud": "crm-app",
  "sub": "248289761001",
  "email": "[email protected]",
  "nonce": "n-0S6_WzA2Mj",
  "iat": 1763100000,
  "exp": 1763103600,
  "amr": ["pwd", "mfa"]
}
CheckWhy
Signature with the IdP's published keyProves the IdP issued it
iss matches the expected IdPStops tokens from other issuers
aud equals your client IDStops tokens meant for another app
exp in the futureRejects expired tokens
nonce matches what you sentPrevents replay

How Is SAML Different?

With SAML 2.0, the service provider sends an AuthnRequest, and the IdP returns a signed XML Response, usually posted by the browser to the app's Assertion Consumer Service URL. The app validates the XML signature, issuer, audience restriction, time conditions and that the assertion has not been used before. SAML is common for older enterprise apps; OIDC is preferred for new web and mobile apps. Microsoft documents both for Entra ID.

How Do Sessions and Logout Work?

There are at least two sessions: one at the IdP and one in each app. Signing out of one app does not end the IdP session unless the app calls the IdP's logout endpoint, and other apps keep their own sessions until they expire or receive a logout notification. NIST SP 800-63C covers assertion lifetimes and reauthentication in federated systems.

What Are Common SSO Security Mistakes?

  • Decoding tokens without verifying the signature.
  • Accepting tokens with the wrong audience or issuer.
  • Wildcard or loosely matched redirect URIs.
  • Skipping state checks, allowing login CSRF.
  • Keeping local password login as a backdoor after SSO is enabled.
  • Long-lived sessions with no reauthentication for sensitive actions.

Related: OAuth 2.0 and OpenID Connect and 2FA bypass through OAuth misconfiguration. WebAsha offers identity and access management training.

References

Frequently Asked Questions

Single sign-on lets you log in once at an identity provider and then access many applications without entering credentials again.

No. You enter your password only on the identity provider’s page, and the application receives a token or assertion instead.

SAML uses signed XML assertions and suits older enterprise apps, while OpenID Connect uses JSON tokens and suits modern web and mobile apps.

A signed JWT from the identity provider stating who the user is, which app it is for, and when it expires.

PKCE ties the authorisation code to the app that requested it, so an intercepted code cannot be exchanged by an attacker.

Each app and the identity provider keep separate sessions, so full logout requires the identity provider and apps to coordinate.

Usually yes, because MFA and monitoring are applied in one place, but the identity provider must be protected very carefully.

The signature, issuer, audience, expiry and nonce, before trusting any of the identity information the token contains.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.