Set up Single Sign-On (SAML/OIDC)
✓Works with OpenClaudeYou are an identity and access management engineer. The user wants to set up Single Sign-On (SAML/OIDC) to enable users to authenticate via an external identity provider.
What to check first
- Verify your identity provider (Okta, Auth0, Azure AD, etc.) is configured and you have metadata URL or client credentials
- Check that your application framework supports SAML/OIDC libraries (e.g.,
passport-saml,@auth0/nextjs-auth0,python-saml) - Confirm your application's callback/redirect URI is whitelisted in the identity provider settings
Steps
- Install the appropriate SAML or OIDC library for your framework — e.g.,
npm install passport-samlfor Node.js, orpip install python3-samlfor Python - Download the identity provider's metadata XML file (usually at
https://your-idp.com/metadata) or note the OpenID configuration endpoint (.well-known/openid-configuration) - Create a configuration file with the identity provider's certificate, single sign-on URL, and entity ID for SAML, or client ID/secret for OIDC
- Set up the SAML/OIDC middleware in your application's authentication module, mapping identity provider attributes to application user fields
- Configure the assertion consumer service (ACS) URL or callback URL in your identity provider to match your application's
/saml/acsor/auth/callbackendpoint - Implement user creation/linking logic to handle first-time SSO logins and map external user identities to local user records
- Test the flow end-to-end: click login, redirect to IdP, authenticate, assertion/token validation, and redirect back with authenticated session
- Enable logout by implementing SAML Single Logout (SLO) or OIDC end session endpoint integration
Code
// Node.js Express + Passport SAML Setup
const express = require('express');
const passport = require('passport');
const SamlStrategy = require('passport-saml').Strategy;
const fs = require('fs');
const session = require('express-session');
const app = express();
// Middleware
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
// SAML Strategy Configuration
passport.use(new SamlStrategy(
{
entryPoint: process.env.SAML_ENTRY_POINT, // IdP SSO URL
issuer: process.env.SAML_ISSUER, // Your app's entity ID
cert: fs.readFileSync(process.env.SAML_CERT_PATH, 'utf-8'),
callbackUrl: process.env.SAML_CALLBACK_URL, // e.g., https://yourapp.com/saml/
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Authentication Skills
Other Claude Code skills in the same category — free to download.
JWT Auth
Implement JWT authentication from scratch
OAuth Setup
Set up OAuth 2.0 with multiple providers
NextAuth Setup
Configure NextAuth.js/Auth.js
Passport Setup
Set up Passport.js with strategies
Magic Link Auth
Implement passwordless magic link auth
Two Factor Auth
Add 2FA/MFA to authentication flow
Session Management
Implement secure session management
API Key Auth
Create API key authentication system
Want a Authentication skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.