Published
Enterprise SSO with Entra ID, Google and Okta: A Practical Integration Guide
How to add enterprise SSO with Entra ID, Google and Okta to a company app: OIDC vs SAML, provider comparison, groups, SCIM, token validation and a checklist.
- Written by
- Ali ÖzdurmuşFounder, Veni AI
- Reading time
- 10 min read

Sooner or later a customer's security team asks the same question about your internal tool, portal or B2B product: "Can our people sign in with our own identity provider?" Enterprise SSO with Entra ID, Google and Okta is the answer they expect, and bolting it on late is how teams end up with account-linking bugs and orphaned users. This guide covers the protocols, how the three providers differ, and how to design the auth layer in your own application.
Why Companies Require SSO With Their Own IdP
- Central offboarding. Disable one account in the identity provider (IdP) and access to every connected app ends.
- MFA and conditional access. The customer enforces its own policy (MFA, device state, location) in one place, not in each vendor's login form.
- Audit. Sign-in events land in the customer's logs, next to everything else they monitor.
- No extra passwords. Fewer credentials to leak or phish, which also eases KVKK and GDPR risk reviews.
The Protocols: OIDC, SAML 2.0 and OAuth 2.0
| OpenID Connect (OIDC) | SAML 2.0 | |
|---|---|---|
| Format | JSON Web Tokens (ID token) over OAuth 2.0 | XML assertions |
| Best for | New web apps, SPAs with a backend, mobile | Older enterprise IdPs and apps, customers who mandate SAML |
| Discovery | /.well-known/openid-configuration | Metadata XML exchange |
| Typical flow | Authorization code with PKCE | SP-initiated or IdP-initiated browser POST |
Use OIDC with the authorization code flow and PKCE by default, and add SAML 2.0 when a customer insists on it. Many enterprise customers will, so plan for both behind one interface.
OAuth 2.0 and OIDC answer different questions. OAuth 2.0 scopes and access tokens say what your app may do against an API. The OIDC ID token says who signed in. Never treat an access token as proof of identity, and never use an ID token to call an API. Request the openid scope for sign-in, plus profile and email only if you need them.
Entra ID, Google and Okta Compared
| Microsoft Entra ID | Google (Workspace / Cloud Identity) | Okta | |
|---|---|---|---|
| Protocols | OIDC, OAuth 2.0, SAML 2.0 | OIDC ("Sign in with Google"); custom SAML apps in the Admin console | OIDC and SAML 2.0 |
| Multi-tenant registration | One app registration set to "Accounts in any organizational directory"; each tenant gets a service principal on consent | One OAuth client serves any Google account; restrict to an organization via the hd claim | No central registration; each customer org creates its own OIDC or SAML app |
| Group / role claims | groups (optional claim) and app roles; overage above 200 groups (JWT) or 150 (SAML) means a Graph lookup | SAML: map groups in the Admin console (max 75 groups per app); OIDC ID token carries no group list | groups claim configured per app or authorization server |
| SCIM provisioning to your app | Provisioning service speaks SCIM 2.0 to a custom endpoint | Outbound SCIM to custom SAML apps documented as beta with limited availability | SCIM 1.1 and 2.0; sends create, update and active=false on deactivation |
| MFA / conditional access | Conditional Access needs Entra ID P1 (risk-based policies need P2); security defaults are free | Configured by the customer admin in Google | Configured by the customer admin in Okta |
| Admin consent | App-only and some delegated permissions need tenant admin consent; admins can disable user consent | Not an equivalent step for plain sign-in | Admin assigns users or groups to the app |
Sources: Microsoft Learn (ID token reference, multitenant guidance, Conditional Access), Google Workspace Admin help and OpenID Connect docs, Okta developer docs. Okta's docs do not say which plan includes which provisioning features, so confirm with the customer's license; plan limits change.
Configuration values per provider
| Provider | Issuer / discovery | Notes |
|---|---|---|
| Entra ID | https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration | {tenant} is a tenant ID or domain, or common / organizations for multi-tenant sign-in |
https://accounts.google.com/.well-known/openid-configuration | iss is https://accounts.google.com or accounts.google.com | |
| Okta (org server) | https://{oktaDomain}/.well-known/openid-configuration | Issuer is https://{oktaDomain} |
| Okta (custom server) | https://{oktaDomain}/oauth2/{serverId}/.well-known/openid-configuration | Custom servers need API Access Management |
Designing the Auth Layer in Your App
1. One abstraction, one connection per tenant
Store an idp_connection per customer tenant: protocol (oidc or saml), issuer or metadata URL, client ID, secret reference, allowed domains and the group-to-role map. Your code talks to an interface (start_login, handle_callback, logout); each provider is an adapter behind it.
2. Tenant discovery by email domain
Ask for the work email first, look up the domain in a verified-domain table, and redirect to that tenant's IdP. Only verified domains (for example by a DNS TXT record) may route to a connection, otherwise a customer could claim another company's domain.
3. Identify users by stable IDs, never by email
Key the account on the pair (connection, sub). On Entra, Microsoft recommends sub or oid with tid for routing, and says the email claim is mutable and must never be used for authorization. Google says the same: always use sub. Never link an incoming login to an existing account just because the email matches, since that is the classic account-takeover path in multi-tenant apps. Link only through a verified domain plus an explicit step, such as an invite.
4. Map groups to roles
Map IdP group IDs (not display names) to app roles in the tenant's connection settings, and default to the lowest role. Handle Entra overage: if the groups claim is replaced by a pointer, call Microsoft Graph or fall back to app roles assigned in Entra.
5. JIT provisioning vs SCIM
| Just-in-time (JIT) | SCIM | |
|---|---|---|
| Creates user | At first login | Before first login |
| Removes user | Not on its own; the user simply cannot sign in any more | Yes: the IdP deactivates the user in your app |
| Effort | Low | A SCIM 2.0 /Users and /Groups endpoint plus token auth |
Start with JIT. Offer SCIM to customers who need deprovisioning to be provable, because with JIT alone a user who is disabled in the IdP keeps any existing session and API tokens in your app until they expire.
6. Sessions, refresh and logout
- Keep your own short session (for example 8 hours absolute, shorter idle) in an HttpOnly, Secure, SameSite cookie. Do not forward the IdP's tokens to the browser.
- Re-check the IdP only when you need fresh claims. Use refresh tokens server-side if you call the IdP's APIs, and drop them on logout.
- Logout means clearing your session and redirecting to the IdP's
end_session_endpointwhere one exists. Microsoft documents both steps; doing only one leaves the user signed in somewhere.
7. Multi-tenant pitfalls and keys
- Validate
issandaudon every token. For Entra with thecommonororganizationsauthority, the issuer differs per tenant, so Microsoft's guidance is to check thatissmatches the published metadata and contains the token'stid, then checktidagainst the tenants you have onboarded. - Verify the
nonceandstateyou issued. - Fetch signing keys from the provider's JWKS URI and cache them, refreshing when you see an unknown
kid. Never pin a single key; providers rotate them. - Log every sign-in, failure, role change and provisioning event with tenant, user ID and IdP, and keep the logs for the period your customers' audits require.
A Token Validation Example
PyJWT verifies the signature against the JWKS, plus aud, iss and exp:
import jwt # PyJWT, with the crypto extra: pip install "pyjwt[crypto]"
from jwt import PyJWKClient
def validate_id_token(token: str, conn) -> dict:
# conn: this tenant's stored connection (jwks_uri, client_id, issuer, nonce)
signing_key = PyJWKClient(conn.jwks_uri).get_signing_key_from_jwt(token)
claims = jwt.decode(
token,
signing_key.key,
algorithms=["RS256"],
audience=conn.client_id,
issuer=conn.issuer, # exact value for this tenant
options={"require": ["exp", "iat", "iss", "aud", "sub"]},
)
if claims.get("nonce") != conn.nonce:
raise jwt.InvalidTokenError("nonce mismatch")
return claimsFor Entra multi-tenant sign-in, build conn.issuer as https://login.microsoftonline.com/{tid}/v2.0 from the tid of an onboarded tenant, never from the token itself. Reuse one PyJWKClient per JWKS URI so its key cache works.
Build vs Buy: Direct Integration or an Identity Broker
| Option | Fits when | Trade-off |
|---|---|---|
| Direct integration | You have a few providers and strong in-house security skills | You own every edge case, key rollover and SAML quirk |
| Identity broker (Auth0, Keycloak, WorkOS and similar) | Many customers with mixed IdPs | Another dependency, cost or hosting; you learn its model instead |
| Microsoft Entra External ID | Customer-facing sign-up and sign-in on the Microsoft platform | Built for customer identity (CIAM); it supports federation with custom OIDC and Entra ID, so check it covers your B2B scenario |
Per their docs, Auth0 offers enterprise connections for Azure AD, Google Workspace, Okta Workforce, OIDC and SAML (by plan), Keycloak can broker any OIDC or SAML 2.0 IdP, and WorkOS SSO supports SAML and OIDC IdPs. A broker normalizes claims, but you still own authorization, account linking and audit. Recheck names and plans before choosing.
Security Checklist
- Authorization code flow with PKCE,
stateandnonceon every login - Exact redirect URI matching, HTTPS only
- Signature,
iss,aud,expand tenant (tidorhd) validated per token - Accounts keyed by
suboroid, not by email - Domain ownership verified before routing a domain to an IdP
- Group-to-role mapping by ID, least privilege by default
- Short sessions, server-side logout, session revocation on deprovision
- Client secrets in a secret store, JWKS cached with refresh on unknown
kid - Audit log for sign-in, role and provisioning events
Quick Start
- List the IdPs your customers use and whether they require SAML.
- Build the
idp_connectionmodel and the domain-verification flow. - Implement OIDC with PKCE first; test it with an Entra tenant, a Google Workspace domain and an Okta org.
- Add group-to-role mapping and a safe default role.
- Add SAML, or put a broker in front, when the first customer needs it.
- Add a SCIM endpoint when a customer asks for provable deprovisioning.
- Write a one-page customer runbook (redirect URIs, claims, consent).
Summary
Enterprise SSO is mostly an identity-model problem, not a login-button problem: stable user IDs, per-tenant connections, verified domains, strict token validation and a deprovisioning path. Build those once and Entra ID, Google and Okta become adapters.
Veni AI designs and builds this layer into the internal tools and portals we deliver. See custom AI apps, how we connect existing systems in data integration, our security approach, or talk to us. For related reading, see AI security and prompt injection defense and AI governance and release gates.


