Video in progress
The company needs to pick an identity provider: do we build on Spring Authorization Server ourselves, install Keycloak, or take a cloud service?
A cloud IdP gives the least operational load, Keycloak gives ready-made features and control on your own servers, and Spring Authorization Server gives maximum flexibility but the most work. The choice depends on requirements, data residency and team capacity.
📖 Answer
Authentication is the most expensive place to make a mistake. So I treat "we'll write it ourselves" as the last option, not the default.
Options:
| Cloud (Auth0, Okta, Cognito, Entra ID) | Keycloak | Spring Authorization Server | |
|---|---|---|---|
| Time to launch | Days | Weeks | Months |
| Login UI, MFA, social login, password reset | Ready | Ready | You write it |
| Operations (HA, upgrades, backup) | On the provider | On you | On you |
| Flexibility | Limited | Via plugins/SPI | Full |
| Data residency | In the provider's region | On your own servers | On your own servers |
| Cost | Grows with the number of users | Infrastructure + team time | Mostly team time |
Decision questions:
- Where must the data be stored? If local law requires personal data to stay in the country (this is relevant in Uzbekistan), a foreign SaaS is often out.
- Are there non-standard flows? For example, phone number + SMS code, integration with an internal bank system, custom token claims. Keycloak can do this with an SPI, but for complex cases Spring Authorization Server is cleaner.
- Who will keep it running 24/7? If the IdP goes down, every service goes down. Running Keycloak with a cluster, a database and upgrades is serious work.
- User count and cost: for a B2C product with 10 million customers, the cloud price grows fast.
My usual choice: for internal staff, the corporate IdP the company already has (Entra ID/Google). For customers, if the data must be local, Keycloak. Spring Authorization Server only if the IdP is part of the product itself or the requirements are very specific.
Whichever you choose, services talk only through standard OAuth2/OIDC (spring-boot-starter-oauth2-resource-server, issuer-uri). Then if you swap the IdP later, you don't have to rewrite the services.
Sign up to mark studied questions and save your progress.