Prompt
How do I build one login for multiple apps?
Latest observation
To build one login for multiple apps, you want Single Sign-On (SSO) with a central Identity Provider (IdP).
The basic idea
Instead of each app having its own username/password system:
- Users sign in once with a central auth service
- That service issues a token/session
- Other apps trust that login and let the user in without re-entering credentials
Common architecture
1) Central auth service
A dedicated authentication system handles:
- Login
- Password reset
- MFA
- Sessions/tokens
- User profile data
Examples:
- Auth0
- Okta
- Keycloak
- AWS Cognito
- Azure AD / Entra ID
- Google Identity Platform
Or you can build your own if needed.
2) Use a standard protocol
For modern apps, the usual choice is:
- OpenID Connect (OIDC) on top of OAuth 2.0
This is the most common way to do SSO across:
- web apps
- mobile apps
- APIs
- SPAs
If you’re in an enterprise environment, you may also use:
- SAML for older systems
3) Each app becomes a client
Each app is registered with the central auth provider.
For each app you define:
- client ID
- redirect URI(s)
- allowed logout URI(s)
- scopes/claims
Then each app redirects users to the auth system for login.
Typical login flow
- User opens App A
- App A redirects to the auth server
- User logs in once
- Auth server creates a session and returns an auth code/token
- App A receives the result and logs the user in
- User opens App B
- App B redirects to the same auth server
- Since the user already has a session there, App B logs them in without prompting again
That’s the “one login for multiple apps” experience.
Important design choices
If your apps are on different domains
Use OIDC with redirects. Don’t try to share passwords or local sessions directly between domains.
If your apps are on the same parent domain
You might be tempted to share cookies across subdomains, but that’s usually not the best long-term approach. Central auth via OIDC is cleaner and safer.
If you have APIs
Use access tokens from the auth provider. Apps call APIs with bearer tokens, and APIs validate them.
Security best practices
- Use authorization code flow with PKCE for browser/mobile apps
- Use short-lived access tokens
- Use refresh tokens carefully
- Store tokens securely
- Use HTTPS everywhere
- Support logout and session revocation
- Add MFA for sensitive apps
- Avoid rolling your own login protocol
Minimal implementation pattern
If you’re building this yourself, your architecture usually looks like:
- Auth server: handles identity and issues tokens
- App A / App B / App C: OIDC clients
- User database: centralized user store
- Session store: server-side session for auth provider
- JWKS/public keys: for apps/APIs to verify tokens
Best option if you want fastest results
If you want this working quickly, use:
- Keycloak if you want self-hosted
- Auth0 / Okta if you want managed service
- Cognito if you’re already on AWS
In one sentence
Build a central identity provider and have all apps authenticate through it using OpenID Connect / OAuth 2.0.
If you want, I can also give you:
- a simple architecture diagram,
- a step-by-step implementation guide, or
- example code for React + Node.js + OIDC.