Prompt
How do I centralize customer identities across multiple apps and APIs?
Latest observation
To centralize customer identities across multiple apps and APIs, you typically want to introduce a single identity layer that all systems trust for login, profile, authorization, and account linking.
Core approach
1) Use a central Identity Provider (IdP)
Pick a platform to act as the source of truth for identity:
- Auth0
- Okta
- Azure AD B2C / Entra External ID
- AWS Cognito
- Keycloak (self-hosted)
- FusionAuth
- Cognito + custom profile store for simpler setups
The IdP handles:
- Authentication
- SSO across apps
- Social login / enterprise login
- MFA
- Token issuance
- User federation
- Account linking
2) Standardize on OIDC/OAuth2
For modern apps and APIs:
- OIDC for user authentication
- OAuth 2.0 for delegated authorization
- Use JWT access tokens for API access when appropriate
Typical flow:
- User logs in via the IdP
- App receives an ID token and access token
- App/API validates token signature and claims
- APIs authorize based on scopes/roles/claims
3) Maintain one canonical customer profile
Beyond login, keep a central customer record in a profile service / customer identity store:
customer_idas the canonical identifier- email(s)
- phone number(s)
- verified identities
- external identity links
- preferences
- consent and privacy flags
- tenant/org membership
- account status
This store becomes the system of record for customer identity data, while the IdP handles authentication.
4) Link multiple identities to one customer
Customers may sign in with:
- email/password
- Apple
- Microsoft
- SAML enterprise login
- phone number
- legacy credentials
Use an identity linking model:
- One internal customer ID
- Many external identity records
- A confidence/matching strategy for merging identities
Example:
customer_id = 12345- linked identities:
google-oauth2|abcauth0|john@example.comsaml|enterprise-user-998
5) Centralize authorization decisions
If multiple apps and APIs need consistent permissions:
- Define roles/scopes/claims centrally
- Consider a policy engine like:
- OPA
- AWS Cedar
- Okta/Auth0 authorization features
- Put coarse-grained authorization in tokens and fine-grained checks in services
6) Use an identity event bus
To keep systems in sync, publish identity events:
customer.createdcustomer.updatedidentity.linkedemail.verifiedpassword.changedcustomer.disabled
Consumers:
- CRM
- billing
- support tools
- analytics
- data warehouse
- marketing automation
7) Build app and API integration patterns
For apps:
- Use OIDC login redirects
- Store only session or token references
- Avoid duplicating password storage
For APIs:
- Validate access tokens
- Map token
subclaim to your internalcustomer_id - Use a userinfo/profile endpoint when more details are needed
Recommended architecture
Client apps → authenticate with IdP → get tokens
APIs → validate IdP-issued tokens → call customer profile service for canonical identity data
Profile service
→ stores canonical customer_id
→ links external identities
→ publishes identity events
Downstream systems → subscribe to identity events → keep local copies only when needed
Key design choices
Choose one canonical ID
Never use email as the primary ID.
- Emails change
- Users can have multiple emails
- Email can be reused or unverified
Use an immutable internal ID instead.
Decide your source of truth
- Authentication truth: IdP
- Customer profile truth: identity/profile service
- Authorization truth: policy engine / claims model
Plan account matching carefully
Use rules such as:
- exact verified email match
- phone verification
- federated identity provider subject ID
- manual support review for ambiguous matches
Support account recovery and merge
You’ll need workflows for:
- merging duplicate accounts
- unlinking identities
- resolving shared emails
- restoring accounts after provider changes
If you want a practical stack
A common setup:
- Auth0 or Keycloak for login/SSO
- PostgreSQL for central customer identity store
- Redis for session/cache
- API gateway for token enforcement
- Kafka/SNS/SQS/PubSub for identity events
- OPA/Cedar for authorization
Minimal implementation checklist
- Pick an IdP
- Use OIDC/OAuth2 everywhere
- Create a canonical
customer_id - Build a profile service with linked identities
- Validate tokens in every API
- Add identity events
- Define merge/link/unlink workflows
- Centralize consent and account status
- Audit all identity changes
If you want, I can also provide:
- a reference architecture diagram,
- a database schema for centralized identities, or
- an implementation plan for a specific stack like Auth0, Keycloak, AWS Cognito, or custom microservices.