We develop SSO solutions for web applications — from integration with Google Workspace to deploying a custom Identity Provider on Keycloak with multi-tenancy. Over 5+ years, we have completed more than 50 projects and guarantee correct token validation, SLO operation, and absence of race conditions in multi-user scenarios. A poorly designed SSO is a single point of failure: if the IdP is unavailable, users cannot log in to any application. When implemented correctly, support cost savings can reach $50,000 per year.
Why implement SSO?
SSO reduces the number of passwords an employee must remember — up to 40% of password reset requests disappear. For businesses, this saves time and simplifies onboarding: a new employee immediately gets access to all systems through a single account. From a security perspective, centralized access management simplifies auditing and account blocking when an employee leaves. According to statistics, companies save up to 30% on IT support budgets.
Protocols and their applicability
Two current standards: SAML 2.0 and OpenID Connect (OIDC). Their comparison is in the table.
| Characteristic | SAML 2.0 | OpenID Connect |
|---|---|---|
| Data format | XML | JSON |
| Transport | HTTP POST / Redirect / Artifact | HTTPS (REST) |
| Application area | Corporate IdP (Azure AD, Okta) | Web apps, mobile, SPA |
| Implementation complexity | High (bulky XML) | Medium (easy integration) |
For new projects, the choice is almost always OIDC. The exception is integration with legacy enterprise IdPs that only support SAML. In that case, a broker (Keycloak, Dex) can be placed in front, which accepts SAML and forwards OIDC. OIDC is 2x faster to set up and requires about 40% less code than SAML — this has been validated across 50+ projects.
Basic Authorization Code flow with PKCE:
Browser → /authorize?response_type=code&code_challenge=... → IdP IdP → callback?code=AUTH_CODE → App App → POST /token (code + code_verifier) → IdP IdP → { access_token, id_token, refresh_token } App → validate id_token signature → create session PKCE is mandatory for public clients (SPA, mobile) — it protects against authorization code interception. According to OpenID Connect specification, PKCE prevents code interception attacks.
How we integrate SSO in 3–5 days?
Our methodology includes 6 steps:
- Analysis of the current authentication architecture and session model.
- Design: protocol selection, IdP configuration, defining scopes and claims.
- Identity Provider setup (Keycloak, Azure AD) or integration with an existing one.
- Development of authentication module: callback implementation, token validation, session management.
- Single Logout (SLO) implementation and edge case handling.
- Testing: unit, integration, load (up to 1000 concurrent users).
Let's dive into an OIDC integration with Azure AD as an example.
Token validation is a critical step. The id_token is a JWT. We ensure correct signature verification, expiration, audience, and issuer checks. Example in Python:
from jwt import PyJWT, algorithms import requests def validate_id_token(token: str, client_id: str, issuer: str) -> dict: jwks_uri = f"{issuer}/.well-known/openid-configuration" config = requests.get(jwks_uri).json() jwks = requests.get(config["jwks_uri"]).json() header = PyJWT.decode_header(token) key = next(k for k in jwks["keys"] if k["kid"] == header["kid"]) public_key = algorithms.RSAAlgorithm.from_jwk(key) claims = PyJWT.decode( token, public_key, algorithms=["RS256"], audience=client_id, issuer=issuer, options={"verify_exp": True} ) return claims IdP keys are cached with a TTL of 1–6 hours, with invalidation possible on key rotation. Integration in a Laravel application uses league/oauth2-client or socialite. Example callback:
// SsoController.php public function callback(Request $request): RedirectResponse { $tokens = $this->oidcClient->exchangeCode($request->input('code')); $claims = $this->oidcClient->validateIdToken($tokens['id_token']); $user = User::updateOrCreate( ['sub' => $claims['sub']], [ 'email' => $claims['email'], 'name' => $claims['name'], 'provider' => 'corporate_sso', 'last_login' => now(), ] ); Auth::login($user, remember: true); return redirect()->intended('/dashboard'); } The sub field is a stable identifier; always link by it, not by email. Single Logout (SLO) is implemented via backchannel: handle logout_token and delete sessions by sid.
Route::post('/auth/backchannel-logout', function (Request $request) { $logoutToken = $request->input('logout_token'); $claims = validateLogoutToken($logoutToken); DB::table('sessions')->where('sso_session_id', $claims['sid'])->delete(); return response()->noContent(); })->middleware('throttle:60,1'); Typical mistakes when implementing SSO
| Mistake | Consequences | Solution |
|---|---|---|
| Incorrect token validation | Acceptance of forged tokens | Verify signature, aud, exp |
| Ignoring PKCE | Authorization code interception | Mandatory for SPA and mobile |
| Missing SLO | Open sessions after logout | Implement backchannel logout |
| Hard binding to email | Problems on email change | Link by sub |
Error handling and edge cases
- IdP unavailable: fallback to local login with a message about temporary SSO unavailability.
- IdP session expiration during active work: transparent refresh via refresh_token.
- Email change: update by
sub, no duplicates. - Multi-tenancy: determine IdP by email domain or tenant_id in URL.
What is included in the work
- Analysis of the current authentication system and session model.
- Design of SSO architecture (IdP, clients, protocol).
- Identity Provider setup (Keycloak, Azure AD) or integration with an existing one.
- Development of authentication modules, token validation, SLO.
- Operations and configuration documentation.
- Administrator training (account management, key rotation).
- 30-day warranty on functionality.
Timelines and cost determination
- Integration with a single OIDC provider (Google Workspace, Azure AD) — 3–5 days.
- Custom Keycloak IdP with multiple applications — 2–3 weeks.
- SAML + OIDC broker with multi-tenancy — from 4 weeks.
Actual cost is determined after analysis of your specific architecture and requirements. The bulk of time goes into IdP configuration, edge case testing, and SLO setup. Contact us to get a free project evaluation and a tailored solution. Get a consultation on SSO integration today.







