Prompt

How do I build SAML and OIDC support into one app?

Technology / Identity & Access2 observationsLast seen Nov 19, 2026

Latest observation

Nov 19, 2026OpenAI APIWeb search: off

To build both SAML and OIDC support in one app, the cleanest approach is to put an authentication abstraction layer in front of your app and implement each protocol as a separate adapter.

Recommended architecture

1) Create a common internal user model

Regardless of whether the user logs in via SAML or OIDC, convert the result into a single internal identity object, for example:

  • userId
  • email
  • displayName
  • roles/groups
  • idpType (saml or oidc)
  • idpIssuer / tenant
  • externalSubjectId

This lets the rest of your app stay protocol-agnostic.


2) Build two auth handlers

Implement separate login/callback flows:

OIDC flow

  • Redirect user to the OIDC authorization endpoint
  • Receive callback with code
  • Exchange code for tokens at the token endpoint
  • Validate:
    • id_token signature
    • issuer
    • audience
    • nonce
    • expiration
  • Map OIDC claims to your internal user model

SAML flow

  • Redirect user to the IdP with a signed AuthnRequest or accept IdP-initiated login
  • Receive SAMLResponse at your ACS endpoint
  • Validate:
    • XML signature
    • audience
    • issuer
    • destination
    • conditions / timestamps
  • Map SAML attributes to your internal user model

3) Normalize identities

Use a shared mapping layer so both protocols end up producing something like:

{
  "userId": "internal-123",
  "email": "alice@example.com",
  "displayName": "Alice Smith",
  "roles": ["admin"],
  "idpType": "oidc",
  "idpIssuer": "https://login.example.com"
}

4) Keep sessions separate from protocols

After authentication, issue your own app session:

  • server-side session cookie, or
  • your own JWT/session token

Don’t rely directly on SAML assertions or OIDC tokens for every request unless you intentionally design for stateless auth. Usually you:

  • validate at login time
  • create your own application session
  • use that session for authorization in the app

Important design choices

Support multiple identity providers

You may need:

  • several OIDC providers
  • several SAML IdPs
  • routing based on email domain, tenant, or user selection

Common patterns:

  • IdP discovery by email domain
  • tenant-specific config
  • “Login with Enterprise SSO” page with provider selection

Separate protocol-specific configuration

For each IdP store:

  • issuer / entity ID
  • client ID / secret (OIDC)
  • metadata URL or certificate (SAML)
  • allowed redirect URIs / ACS URLs
  • attribute/claim mapping rules

Be careful with account linking

A user may log in via SAML once and OIDC later. Decide whether to:

  • auto-link by verified email
  • require admin linking
  • maintain separate accounts per IdP

Security requirements

OIDC

  • Use PKCE for public clients
  • Validate nonce
  • Validate issuer, audience, signature, exp, azp as needed
  • Restrict redirect URIs
  • Use HTTPS only

SAML

  • Validate XML signature properly
  • Check assertion audience, recipient, destination
  • Enforce clock skew limits
  • Reject unsigned or improperly signed assertions
  • Be cautious of XML parsing vulnerabilities

Practical implementation pattern

Option A: Build it yourself

Good if you need full control, but more work and risk.

Structure:

  • AuthController
  • OidcStrategy
  • SamlStrategy
  • IdentityMapper
  • SessionService
  • IdpConfigService

Option B: Use an identity library/framework

Many frameworks already support both, or make it easier:

  • Java/Spring Security
  • .NET / ASP.NET
  • Node.js with passport-style strategies plus SAML/OIDC libraries
  • Python with auth libraries for each protocol

Option C: Put an identity broker in front

If you want to avoid maintaining protocol complexity yourself, use:

  • Keycloak
  • Auth0
  • Okta
  • Azure AD B2C
  • Ping
  • Cognito (more OIDC-centric, SAML federation possible in some setups)

Then your app only speaks one protocol to the broker, and the broker handles SAML/OIDC federation upstream.

This is often the best choice if:

  • you need many enterprise customers
  • you want faster setup
  • you want to reduce security/maintenance burden

Suggested flow for your app

  1. User hits login page
  2. App determines or asks for org/tenant
  3. App selects SAML or OIDC provider for that tenant
  4. Redirect to correct IdP
  5. Receive callback/assertion
  6. Validate response
  7. Map to internal user
  8. Create app session
  9. Proceed to app

Best practice recommendation

If you’re starting from scratch:

  • Use OIDC as the default modern protocol
  • Add SAML only for enterprise/legacy IdPs
  • Implement a shared identity abstraction
  • Consider using an identity broker if you expect multiple enterprise customers

If you want, I can also give you:

  1. a reference architecture diagram,
  2. a database schema for SAML/OIDC tenant config, or
  3. a sample implementation in a specific stack like Node, Python, Java, or .NET.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.