Your security team just sent you the mandate: no more individual credentials. Everyone goes through your corporate identity provider. SSO only. And they want it working by next sprint.
Sound familiar? If you’re running Claude Code in an enterprise environment, you’ve probably hit this requirement. It’s one of those integration projects that sounds straightforward on paper—connect to your Okta instance, enable SAML, done—but in practice, there’s a lot more happening under the hood. Token lifetimes, session management, deprovisioning workflows, claim mapping, JIT user creation—it all matters more than you’d think.
Here’s the thing: SSO isn’t just about “logging in with your work account.” In enterprise environments, it’s about creating a seamless authentication experience while maintaining strict security boundaries, tracking user sessions, handling privileged access, and ensuring that when someone leaves your company, they’re actually removed from Claude Code within minutes, not weeks.
Let’s talk about how to make this work properly.
Why Enterprise SSO Is Non-Negotiable
Before diving into the technical details, let’s be honest about why your security team is demanding SSO in the first place. It’s not arbitrary bureaucracy. Well, sometimes it is, but there are legitimate reasons underneath.
When you rely on application-specific credentials for Claude Code—usernames and passwords stored separately for each tool—you create a security nightmare. Each tool becomes a separate attack surface. Each tool has a separate password reset process. When an employee leaves your organization, you have to manually remove them from Claude Code and hope you remember all the other systems they had access to. Spoiler: you won’t remember all of them.
SSO solves this by making your corporate identity provider the source of truth. Your Okta instance, Azure AD, or Google Workspace becomes the single system where all authentication decisions flow through. Someone gets hired, they get a corporate account, and they automatically have access to Claude Code. Someone leaves, you deactivate their account in one place, and they’re locked out of Claude Code and every other integrated application simultaneously.
This architecture provides several critical benefits:
Centralized credential management: Passwords are managed in one place. Password complexity policies, MFA requirements, and password resets happen in your identity provider, not scattered across a dozen applications.
Audit trails: Every login to Claude Code is logged back to your identity provider. You have a complete audit trail of who accessed what, when, and from where. This matters for compliance audits, security investigations, and “who broke production at 3 AM?” forensics.
Immediate access revocation: When someone leaves, they’re gone. Not “gone once we remember to disable their account here.” Gone immediately, across all applications, because you disabled them in one central place.
Conditional access: Your identity provider can enforce policies like “block logins from outside the corporate network” or “require MFA for administrative access.” These policies apply to Claude Code automatically.
Delegation of responsibility: Your identity team owns Claude Code authentication. Your Claude Code team doesn’t have to manage credentials, password resets, or account recovery. Everyone stays in their lane.
This is why “just use SSO” is a reasonable requirement, even if it feels like extra work upfront. The alternative is credential sprawl, audit nightmares, and security vulnerabilities that accumulate over time.
Understanding SAML vs. OIDC: Which Protocol Does Claude Code Use?
Here’s where your first architectural decision comes in. Claude Code supports both SAML 2.0 and OpenID Connect (OIDC). They do similar things but take different approaches, and understanding the difference matters for choosing the right integration path.
SAML 2.0 is the older protocol, designed in the mid-2000s for enterprise SSO. It works by passing XML assertions between your identity provider and Claude Code. Here’s the flow:
- You visit Claude Code
- Claude Code says “I don’t know who you are, go ask your identity provider”
- Your browser redirects you to your identity provider (Okta, Azure AD, etc.)
- You authenticate (username/password, MFA, biometric, whatever your org requires)
- Your identity provider creates an XML assertion saying “this is user [email protected], they’re part of the engineering team, their email is [email protected]”
- Your browser carries this assertion back to Claude Code
- Claude Code validates the assertion’s signature, creates a session, and logs you in
OIDC is the newer protocol, built on OAuth 2.0. It works differently:
- You visit Claude Code
- Claude Code says “I don’t know who you are, authenticate with your identity provider”
- Your browser gets redirected to your identity provider
- You authenticate
- Your identity provider responds with an ID token (a JSON Web Token, or JWT)
- Claude Code validates the token’s signature and extracts claims from it
- Claude Code creates a session and logs you in
The key difference? SAML passes XML assertions, OIDC passes JSON tokens (JWTs). SAML is more mature and has broader enterprise support. OIDC is newer, more flexible, and easier to integrate with modern applications. Most new SaaS applications prefer OIDC; legacy enterprise applications often require SAML.
For Claude Code specifically, most modern deployments use OIDC, though SAML is fully supported. Here’s the practical implication: if you’re on Okta, you can use either. If you’re on Azure AD, you’re typically using OIDC (though SAML is available). If you’re on Google Workspace, you’re likely using OIDC.
The choice usually doesn’t matter that much—both are secure, both work fine—but it’s good to understand what’s happening under the hood instead of just clicking “enable SSO” and hoping for the best.
Configuring Claude Code SSO: The Walkthrough
Let’s say you’re using Okta (the most common enterprise choice). Here’s how you’d set up OIDC integration with Claude Code.
Step 1: Create an Okta Application
First, you log into your Okta admin console and create a new application. You’ll choose “OIDC – OpenID Connect” as the protocol and “Web Application” as the application type. This tells Okta you’re integrating a web-based tool.
Okta will ask for your redirect URIs. This is critical—you’re telling Okta “when users authenticate, send them back to these URLs.” For Claude Code, you’d typically enter something like:
https://claude-code.company.com/auth/callback
https://claude-code-dev.company.com/auth/callback
https://claude-code-staging.company.com/auth/callback
These URLs must be HTTPS (Okta won’t accept HTTP), and they must exactly match what Claude Code expects. Off by a single character, and authentication fails.
Step 2: Configure Claims and Scopes
Now you tell Okta what information to send to Claude Code about authenticated users. This happens via “claims” in your ID token. The standard claims are:
sub: The unique subject identifier (usually a UUID)email: The user’s email addressname: The user’s full namegroups: The groups the user belongs to (useful for authorization)
For Claude Code, you want at least email, name, and groups. Here’s why groups matters: it’s how you’ll implement role-based access control. If you want to give administrative access only to people in your “claude-admins” group, Claude Code checks that groups claim.
You can add custom claims if you need them. Want to send department or cost_center? You can do that. Just make sure you document what claims you’re sending and why—future you will appreciate it.
Step 3: Configure on the Claude Code Side
Now you’re in Claude Code’s configuration. You’ll tell Claude Code about your Okta instance. This typically means entering:
oidc:
provider_url: https://company.okta.com
client_id: <your client id>
client_secret: <your client secret>
redirect_uri: https://claude-code.company.com/auth/callback
scopes:
- openid
- email
- profile
- groups
The provider_url is your Okta domain. The client_id and client_secret are credentials that prove Claude Code is who it claims to be when talking to Okta. Treat the client secret like a password—don’t commit it to git, don’t paste it in Slack. Use your secret management tool (Vault, AWS Secrets Manager, whatever you have).
The scopes tell Okta what information you’re requesting. openid is required (it tells Okta you’re doing OIDC). email and profile are standard. groups gets you group membership, which is crucial for authorization.
Step 4: Test the Flow
Before rolling this out, test it. Visit your Claude Code instance, try to log in, and verify that:
- You’re redirected to Okta
- You authenticate successfully
- You’re redirected back to Claude Code
- You’re logged in and can see your account details
If this works, congratulations, you’re past the hardest part. If it doesn’t, the problem is usually one of:
- Redirect URI mismatch (Okta and Claude Code are expecting different URLs)
- Clock skew (your server’s time is significantly different from Okta’s; usually matters for JWT validation)
- Client secret is wrong or missing
- Okta application isn’t assigned to your user (you created the app but didn’t add your user to it)
Check your logs. Most OIDC failures leave a breadcrumb trail in the application logs. Look for messages about “invalid redirect_uri” or “token validation failed.” These point you directly to the problem.
Just-in-Time Provisioning: Automatic User Creation
Here’s where the real magic happens. Instead of manually creating user accounts in Claude Code, you can configure JIT (Just-in-Time) provisioning. This means: every new user who successfully authenticates with Okta automatically gets a Claude Code account created on the fly.
Here’s how it works:
- Alice from your marketing team visits Claude Code for the first time
- She’s redirected to Okta to authenticate
- Okta verifies her identity and sends her ID token back to Claude Code
- Claude Code’s JIT provisioning logic runs: “I don’t have an account for [email protected], but her identity is verified by Okta, so I’ll create one now”
- A new Claude Code account is created with Alice’s email, name, and group memberships
- She’s logged in and can start using Claude Code
No manual account creation. No “I forgot to create accounts for the marketing team.” No delays between hire date and access to tools. This is genuinely useful.
To enable JIT provisioning, you need to:
-
Configure the claim mapping: Tell Claude Code which claim contains the email (usually
email), name (usuallyname), and groups (usuallygroups) -
Set a default role: When a new account is created via JIT, what permissions should they have? Usually this is
user(read-only access) ordeveloper(can create and modify projects). Definitely notadminunless you’ve really thought this through. -
Enable auto-provisioning: Flip the switch that says “automatically create accounts for authenticated users”
There’s one important gotcha: JIT provisioning only creates accounts; it doesn’t handle group membership changes. If someone gets promoted from engineer to manager and gets added to your “managers” group in Okta, their existing Claude Code account won’t automatically update their group membership. This is by design—you don’t want permission changes happening silently in the background. Instead, you need to either:
- Manually update their Claude Code group membership when Okta changes
- Configure periodic synchronization (SCIM, System for Cross-domain Identity Management) to pull updates from Okta
- Accept that group membership in Okta and Claude Code might be out of sync and handle this manually
Most organizations go with SCIM synchronization. It’s an additional integration layer that keeps user attributes synchronized between your identity provider and Claude Code. It’s more work upfront but saves you from manual sync headaches later.
Deprovisioning: The Other Half of the Story
Creating users is great. Removing them when they leave your organization is even more critical—and more often forgotten.
Deprovisioning means: when someone leaves your company or moves to a department that shouldn’t have access to Claude Code, they’re immediately locked out. No delays. No forgotten disabled accounts. No security vulnerabilities from ex-employees retaining access.
There are two approaches:
Automatic deprovisioning via SCIM: If you’ve configured SCIM synchronization, you get this for free. When someone is deactivated in Okta, SCIM notifies Claude Code, and their account is deactivated automatically. This is the ideal scenario—it’s fully automatic, no manual steps, no room for error.
Manual deprovisioning workflows: If you’re not using SCIM, you need a process: when someone leaves, your IT team disables their Okta account. They should also notify the Claude Code team (or have a checklist) to deactivate that person’s Claude Code account. This works but relies on humans remembering to do things, which is a reliability problem.
Here’s the thing many teams miss: disabling the Okta account automatically locks them out of Claude Code on the next login attempt. But if they’re already logged in—with an active session—they remain logged in until that session expires. This is actually fine from a security perspective (their session will eventually expire), but some organizations want immediate lockout.
If you need immediate revocation, you can configure session invalidation: when Okta disables an account, it can send a revocation notification to all connected applications, including Claude Code. Claude Code will then immediately invalidate all active sessions for that user. This is more aggressive but provides immediate lockout.
Token Lifecycle Management: When Sessions Matter
Let’s talk about what happens after authentication. Once you’ve proven who you are, Claude Code creates a session. This session has a lifetime—it can last minutes, hours, or days depending on your policy. When the session expires, you need to re-authenticate.
Here’s where it gets interesting in SSO environments: there are actually multiple lifetimes happening simultaneously:
Identity token lifetime: The OIDC ID token that Okta sends Claude Code is typically valid for 60 minutes. After 60 minutes, if Claude Code needs to refresh it, the token is stale and can’t be used.
Access token lifetime: If you’re using access tokens (for API access), these also expire. Typically shorter than ID tokens—maybe 15 or 30 minutes.
Refresh token lifetime: If you’ve requested a refresh token, it lets Claude Code get a new access token without requiring the user to re-authenticate. Refresh tokens usually live longer—days or weeks.
Session lifetime: Claude Code’s internal session—the cookie that keeps you logged in—has its own lifetime. This might be 8 hours, 24 hours, or even longer.
Okta session lifetime: Meanwhile, your Okta session has its own lifetime. This is separate from Claude Code’s session.
Why does this matter? Consider this scenario:
- You authenticate with Okta and log into Claude Code
- Your Claude Code session is set to 24 hours
- Your Okta session is set to 8 hours
- After 8 hours, your Okta session expires
- After 12 hours (still within Claude Code’s 24-hour window), you refresh a page
- Claude Code tries to use its session, but your Okta session is gone
- Behavior depends on configuration: either you’re kicked back to log in, or Claude Code silently refreshes your Okta session
This is why coordinating session lifetimes matters. If Claude Code’s session is much longer than Okta’s, you might end up with stale sessions. If Claude Code’s session is much shorter, you’re forcing re-authentication more often than necessary.
The best practice: set Claude Code’s session lifetime slightly shorter than Okta’s. This ensures that when Claude Code needs to refresh authentication, Okta’s session is still valid. Also, make sure Claude Code is configured to handle silent re-authentication—if the session is stale, silently redirect through Okta’s authorization endpoint to get a fresh token, rather than forcing the user to explicitly log in again.
Troubleshooting Common Integration Issues
You will hit problems. Every SSO integration has them. Here are the most common ones and how to fix them.
Problem: “Redirect URI mismatch”
You see an error like “redirect_uri does not match.” This means Okta received a request to redirect back to a URL that Claude Code didn’t register in the Okta application.
Common causes:
- You registered
https://claude-code.company.com/auth/callbackin Okta, but Claude Code is actually athttps://claudecode.company.com(no hyphen) - Okta has
https://claude-code.company.com:8443but Claude Code is running on port 443 - You’re testing with
localhost:3000but forgot to add it to Okta’s approved list
Fix: In your Okta application, carefully review all registered redirect URIs. Make sure they match exactly what Claude Code is sending. If you’re adding a staging environment, register its URL explicitly. Copy and paste to avoid typos; one wrong character breaks everything.
Problem: “Invalid client secret”
Token exchange fails because the client secret is wrong.
Common causes:
- You copied the client secret wrong (you got a truncated version, or accidentally included a newline)
- You rotated the client secret in Okta but didn’t update Claude Code’s configuration
- You’re using the wrong client secret (you created multiple Okta applications and picked the wrong one)
Fix: Regenerate the client secret in Okta’s UI, copy it fresh (avoid pasting through multiple applications), update Claude Code’s configuration, and test immediately. Don’t assume it will work once you’ve “fixed” it later. Test now.
Problem: “Missing required claims”
Claude Code creates the account but with missing information (no email, no name). This usually means the claims aren’t being sent.
Common causes:
- You didn’t request the right scopes. You have
openidbut notemailandprofile - You requested the scopes but didn’t configure them in Okta to be included in the token
- Your Okta application isn’t assigned to your user, so the token doesn’t include claims
Fix: In Okta, go to your application, check the “Claims” tab. Verify that email, name, and any custom claims are configured to be included in the ID token. If they’re configured in Okta but not appearing in Claude Code, the most likely issue is insufficient scopes—update your scope request to include what you need.
Problem: “Session expires too quickly”
Users are getting logged out after 5 minutes, even though the session should last 24 hours.
Common causes:
- Okta session has expired, and Claude Code’s session refresh is checking Okta
- The OIDC ID token has expired, and Claude Code can’t refresh it (usually requires refresh tokens)
- There’s a mismatch between different session lifetimes
Fix: Check your logs. Look for token validation failures or Okta session-related errors. Ensure refresh tokens are enabled in your Okta application and that Claude Code is configured to use them. Align your session lifetimes: Claude Code session < Okta session lifetime, with enough buffer that refreshes succeed.
Problem: “Some users can log in; others can’t”
This is usually a group membership or claim issue.
Common causes:
- Users who can log in are in the group assigned to the Claude Code Okta application; users who can’t aren’t
- Custom claims are only populated for certain user types in your directory
- There’s a typo in the group claim that affects some users
Fix: Check that all users are assigned to the Claude Code application in Okta. Check that group claims are populated for everyone (not just certain user types). Test with a specific user, look at their token, and verify what claims are present.
Rolling Out SSO: The Practical Path
Alright, you’ve tested it. Everything works. Now you need to roll it out to your organization without breaking everything.
Here’s the approach that actually works:
Phase 1: Opt-in for the brave
Enable SSO for people willing to be test subjects. Maybe it’s your security team, or your internal platform team. Let them poke at it, find issues, and report problems. This group is valuable because they’ll try the edge cases that your testing missed. They’ll notice subtle issues like “SSO works fine, but my profile photo isn’t syncing” or “I can log in, but my groups aren’t updating.”
Phase 2: Mandatory opt-in by department
Once you’ve shaken out major issues, require SSO for specific departments. Marketing doesn’t have access to production systems, so they can migrate first. Engineers migrate a week later once you’re confident nothing breaks. This staged rollout gives you time to address department-specific issues. Maybe the sales team uses a different Okta org than engineering—you’ll discover this during their migration.
Phase 3: Fallback credentials
During rollout, keep local credentials working. If someone can’t use SSO for some reason, they can still log in with a username and password. This is a safety valve. After a month, when everyone’s on SSO, you can disable local credentials. Don’t disable them immediately—someone will need them during the transition. Some users might travel internationally, connect through unstable networks, or have unusual Okta configurations. The fallback prevents “everyone is locked out” disasters.
Phase 4: Celebrate and document
Once everyone’s migrated, celebrate that you’ve solved a real security problem. Then, very importantly, document how it all works. Write down your claim mappings, your group structure, your session lifetime decisions. Future you will be grateful when you need to troubleshoot in six months.
Communication and Change Management
Here’s what many teams skip that causes problems: proper communication with users. People fear change, especially around authentication. If someone suddenly can’t log in, they panic. Here’s what works:
Send a heads-up two weeks before launch. Explain what SSO is, why you’re doing it (security, convenience, audit compliance), and what’s changing for them. The message should be simple: “You’ll log in using your Okta account instead of your Claude Code account. Same username, same password you use for everything else.”
Run a FAQ session or office hours right before launch. Some people will ask silly questions (no such thing during authentication changes), some will have legitimate edge case concerns, and you’ll learn about problems you didn’t anticipate.
Create a quick troubleshooting guide: what to do if SSO isn’t working, how to use fallback credentials, who to contact. Make it available on an internal wiki, in email, and in Slack. When someone inevitably gets stuck, you want the solution one click away.
Handling Special Cases and Constraints
Real organizations have special cases that generic SSO docs don’t cover:
Contractors and external partners: If you have contractors who don’t have Okta accounts, SSO breaks their access. Solution: keep local credentials specifically for non-employees. Or create contractor Okta accounts in a separate org. Or use a different authentication method for contractors. None of these is perfect, but you’ll need to choose one.
Service accounts and API access: SSO handles human users fine. But what about your CI/CD pipeline, your scheduled jobs, or your API integrations that need to authenticate? These don’t have Okta accounts. Solution: create service account exceptions that use API keys or personal access tokens. Document which accounts are service accounts so you don’t accidentally deactivate them.
Compliance and audit requirements: Your security team might require that all authentication flows go through SSO, with no exceptions. If that’s your constraint, you’ll need to model service accounts as human users in Okta—create them as special “bot” user accounts, assign them to specific Okta groups, and track their usage.
Multiple identity providers: Some organizations have multiple Okta instances, or they’re migrating from Azure AD to Okta, or they need to support both corporate and acquired-company identity systems. Claude Code can support federation—redirect to a proxy that routes to the right identity provider—but this adds complexity. Plan for this upfront.
Monitoring and Maintenance
SSO integration isn’t a “set it and forget it” thing. You need ongoing monitoring:
Monitor authentication failures: Track failed Okta login attempts. A spike might indicate attackers trying to compromise accounts. A steady stream might indicate configuration issues. Set up alerts: if authentication failures exceed a threshold (maybe 10 failures in 5 minutes), someone should get paged. This catches problems early—misconfigured credentials, certificate issues, or attacks.
Track session invalidation: When you deactivate someone in Okta, monitor that Claude Code actually invalidates their sessions. If deactivated users are still logged in three hours later, something’s wrong. The security implications are serious. Run weekly spot checks: deactivate a test user, verify they can’t access Claude Code within seconds.
Monitor token refresh failures: If Claude Code can’t refresh tokens from Okta, users will get logged out. Monitor this rate. A few failures are normal (network hiccups), but consistent failures indicate misconfiguration. If refresh failures spike, page on-call immediately. This affects all users, not just one.
Audit claim values: Periodically spot-check that claims are being populated correctly. Sample tokens, decode them (they’re JWTs, just base64-encoded), and verify the claims match reality. You can decode JWTs manually at jwt.io, or write a script that periodically decodes tokens and validates their structure. Look for:
- Email claims that are malformed
- Group claims that are missing
- User attributes that should be present but aren’t
Test the revocation flow: Periodically, actually deactivate a test account in Okta and verify that Claude Code locks them out immediately. Don’t assume this works. Test it. Once a month, go through the full workflow:
- Create a test user in Okta
- Add them to your Claude Code application
- Log in as that user
- Deactivate the user in Okta
- Verify they’re immediately locked out
- Attempt to use any active sessions from that user (they should fail)
Setting Up Observability
Beyond basic monitoring, you need visibility into what’s actually happening:
Log all authentication events: Every successful login, failed login, token refresh, and session creation should be logged with timestamps, user identifiers, and source IP. Store these logs for at least 90 days (most compliance frameworks require this). Use structured logging (JSON format) so you can parse and search programmatically.
Create dashboards: Build dashboards showing:
- Authentication success/failure rate over time
- Session duration distribution (are sessions lasting as long as configured?)
- Token refresh frequency (are refresh tokens being used?)
- User activity patterns (is anyone logging in from unusual locations at unusual times?)
Set up alerts for anomalies: Configuration isn’t just for normal operations. Alert on:
- Sudden spike in failed authentications
- User logging in from new geographic location
- More than N failed login attempts from same IP
- Users staying logged in beyond configured session lifetime
- Service account authentication patterns changing
This isn’t paranoia. These patterns often indicate misconfiguration early, before it becomes a larger problem.
Summary and What’s Next
SSO integration transforms how your organization manages access to Claude Code. Instead of scattered credentials and manual account management, you get centralized identity, automatic user creation and removal, audit trails, and immediate access revocation when people leave.
The technical implementation—OIDC or SAML, JIT provisioning, token lifecycle, session management—sounds complex, but it’s manageable once you understand the underlying concepts. The real work is upfront configuration, careful testing, and thoughtful rollout.
Your security team will be happy. Your IT team will be happy. Your users will be happy. And you’ll be happy because you’ve solved a real problem elegantly.
Now go configure it properly, test it thoroughly, and document it clearly. Your future self will thank you.
— -iNet