Blog · Guides

Adding SSO to your application: the implementation checklist

A practical guide to adding SAML and OIDC single sign-on to a web application: per-tenant connection state, assertion validation, sessions, JIT provisioning, logout and certificate rotation.

Casdoor Team · November 1, 2026 · 4 min read

This guide is written by the team that builds Casdoor and describes the standards as published (listed under Sources), with notes on how Casdoor implements them as of November 1, 2026. Spotted a mistake? Tell us.

Adding single sign-on to an application looks like a redirect and a callback. In production it is a small protocol implementation with a long tail of edge cases, one per customer identity provider.

This guide is the checklist for the application side — the service provider — in the order you will actually build it.

Step 1: Decide the protocol per customer

You will likely need both:

  • SAML 2.0 for enterprise customers. Their identity providers speak it, their procurement asks for it, and it is not going away.
  • OpenID Connect for modern providers, mobile apps and anything you control.

The application can support both behind one internal "sign in this user" function: normalize the assertion or token into the same user record, then continue with your own session.

Step 2: Model the per-tenant connection

This is the design decision that determines whether the feature scales.

Each tenant needs its own:

  • Identity provider metadata (entity ID, SSO URL, signing certificate).
  • Attribute mapping: which claim is the email, the name, the groups.
  • Whether JIT provisioning is on.
  • Whether IdP-initiated login is allowed.

Store this as tenant configuration, not code. A single global SAML configuration works for one customer and breaks at the second.

Step 3: Implement the flow

SP-initiated SAML:

  1. The user enters their email or clicks "sign in with SSO".
  2. Look up the tenant's connection; redirect to its SSO URL with a signed SAML request.
  3. The IdP posts a SAML response to your ACS endpoint.
  4. Validate: signature, issuer, audience, recipient, time window, replay.
  5. Map attributes to a local user and start a session.

OIDC:

  1. Redirect to the authorization endpoint with the client ID, scopes and state.
  2. Handle the callback: validate the state, exchange the code for tokens.
  3. Validate the ID token: signature via JWKS, issuer, audience, expiry, nonce.
  4. Map claims to a local user and start a session.

For public clients (single-page and mobile apps), use the authorization code flow with PKCE and do not ship a client secret.

Step 4: Validate properly

The checks that matter, and what happens when they are missing:

Check What goes wrong without it
Signature over the exact assertion or token Anyone can forge a login
Audience / recipient A response for another application is accepted
Issuer A response from another IdP is accepted
Time window with clock skew Valid logins fail, or expired assertions pass
Replay cache on assertion IDs A captured assertion can be reused
State and nonce (OIDC) Login CSRF and token injection

SAML signature validation has a specific trap: XML signature wrapping. Validate the signature over the exact element you read, with a parser that rejects duplicate IDs.

Step 5: Provision users

Two models:

  • JIT: create the user from the assertion on first sign-in. Fast to ship, but does not deprovision anyone.
  • SCIM: the customer's identity provider calls your API to create, update and deactivate users. More work, and what enterprise buyers ask for next.

Most teams ship JIT first, then add SCIM when a customer requires it.

Step 6: Handle logout and sessions

  • Decide session lifetime separately from the IdP session; they are not the same clock.
  • Support single logout if your customers ask: SAML LogoutRequest/Response, or OIDC RP-initiated logout with id_token_hint and post_logout_redirect_uri.
  • On sign-out, end the local session even if the IdP logout fails. The local session is the one that grants access.

Step 7: Plan for certificate and metadata changes

Certificates expire. Metadata changes when a customer rotates keys or migrates IdPs.

  • Store certificates with their expiry date and alert before it passes.
  • Support overlapping certificates during rotation: accept both, then remove the old one.
  • Make metadata refresh a documented operation, not an emergency.

This is the most common cause of "SSO suddenly stopped working" tickets.

Step 8: Test against real identity providers

A local test IdP passes on your machine and proves little. Run the flow against:

  • Okta (the most common enterprise IdP).
  • Microsoft Entra ID (the second most common).
  • Google Workspace (common in mid-market).
  • One SAML IdP you do not control, to catch assumptions.

Test both SP-initiated and IdP-initiated login, a wrong-password path, a deactivated user, and clock skew of a few minutes.

Step 9: Make it self-service

The feature stops being a support burden when customers can configure it themselves: an admin screen with metadata upload or URL, a "test connection" button, and clear error messages that say which check failed.

If you would rather not run the customer's connections yourself, an identity provider such as Casdoor can hold them per organization while your application integrates once. See SSO for SaaS and multi-tenant authentication.

Related reading: identity provider vs service provider, SAML vs OIDC and set up Casdoor as a SAML IdP.

Casdoor is open source and self-hostable, with a hosted option from $9 per month and no per-user fees.