Prompt
How do I handle SSO deprovisioning when a user leaves a company?
Latest observation
Handling SSO deprovisioning well is mostly about making identity your source of truth, automating revocation, and having a fallback for edge cases.
Best-practice approach
1) Use your IdP as the source of truth
If the company uses Okta, Azure AD/Entra, Google Workspace, Ping, etc., your app should trust the IdP for:
- authentication
- account status
- group/role membership
When the user leaves, IT disables the account in the IdP, and that should cascade to your app.
2) Support SCIM provisioning/deprovisioning if possible
If your app supports SCIM, that’s usually the cleanest solution.
What happens:
- User is created in your app when provisioned
- User is updated when attributes/groups change
- User is deactivated when the IdP or directory sends a deprovision event
Recommended deprovision behavior:
- mark the user as
inactiveorsuspended - revoke all sessions/tokens
- disable API keys / personal access tokens
- optionally preserve data for retention/compliance
- don’t hard-delete immediately unless policy requires it
3) Revoke active sessions immediately
When deprovisioning occurs:
- invalidate all server sessions
- revoke refresh tokens and access tokens if you can
- force re-authentication everywhere
- log the action for audit purposes
If you use JWTs, remember:
- you usually can’t instantly “recall” already-issued JWTs unless you check token revocation state or use short lifetimes
- best practice is short-lived access tokens + refresh-token revocation + session blacklist/versioning if needed
4) Deactivate, don’t necessarily delete
Usually, the safest pattern is:
- deactivate the account immediately
- retain records for audit, legal hold, billing, or recovery
- delete later according to retention policy
This avoids accidental data loss and helps with compliance.
5) Handle “login after deprovision” gracefully
If a deprovisioned user tries to sign in:
- deny access
- show a generic message like:
“Your account is no longer active. Contact your administrator.” - avoid exposing whether the account exists if that matters for security
6) Sync group/role changes too
Sometimes offboarding isn’t just disabling a user:
- user may be removed from an access group
- user may be transferred to another org/unit
- access should change immediately based on current group membership
If your app maps permissions from IdP groups, refresh that mapping on each login and via provisioning updates.
7) Build for delayed or missed events
Don’t rely on just one mechanism.
Use multiple layers:
- SCIM deprovision event
- periodic reconciliation job against IdP
- session/token expiry checks
- admin-triggered disable in your app
That way, if an event is missed, the account is still corrected soon.
Recommended deprovisioning flow
- HR/offboarding disables employee in IdP
- IdP sends SCIM
deactivate/deleteor equivalent - Your app:
- sets user to inactive
- revokes sessions/tokens
- removes access to resources
- keeps audit record
- User cannot log in anymore
- Data is retained or deleted per policy
Things to watch out for
- Shared accounts: avoid them entirely if possible
- Local passwords: don’t allow bypassing SSO unless there’s an admin break-glass account
- Admin users: ensure admin access is also governed by IdP and offboarding
- Offline/mobile sessions: plan for token expiry and refresh revocation
- Multi-tenant apps: deprovision from one tenant should not affect access in another tenant unless intended
Practical recommendation
If you’re implementing this in a SaaS app:
- support SCIM
- make sessions revocable
- use short-lived access tokens
- store users as active/inactive
- add a nightly reconciliation job with the IdP
- keep a strong audit trail
If you want, I can also provide:
- a SCIM deprovisioning design
- a database schema for active/inactive users and session revocation
- or a sample offboarding flow for Okta / Entra ID / Google Workspace