
Why I Chose Keycloak
Secure authentication with Keycloak in a modern Spring Boot & Angular architecture.
π Introduction
Modern applications require much more than a simple login page. As soon as multiple users, protected content, and different permission levels become part of the application, identity management turns into a core architectural component.
When I started building this platform, I had to decide whether to develop my own authentication system or rely on an established solution. After evaluating several options, I chose Keycloak.
Instead of reinventing authentication from scratch, I wanted to build the platform itself.
π Authentication Is More Than a Login Form
Many developers think authentication simply means checking a username and password.
In reality, a production-ready authentication system includes far more:
π Secure user authentication
π₯ Role-based authorization
π‘οΈ Access control
π Session management
π« JWT token handling
π Password policies
π Single Sign-On (SSO)
π OAuth2 & OpenID Connect
π Scalability for future growth
Building all of this yourself is possibleβbut it quickly becomes one of the most complex parts of an application.
βοΈ Why I Didn't Build It Myself
Technically, I could have implemented my own authentication system.
However, authentication is not the feature that makes this platform unique.
Instead of maintaining thousands of lines of security-related code, I wanted to invest my time in building new features, writing content, and continuously improving the platform.
Using an established open-source solution significantly reduces maintenance while increasing security.
After comparing different identity providers, Keycloak became the clear choice.
It provides enterprise-grade identity and access management while remaining completely open source.
Keycloak includes:
β OAuth2
β OpenID Connect
β JWT Tokens
β Role-Based Access Control
β User Management
β Identity Federation
β Password Policies
β Session Management
β Multi-Factor Authentication
β Single Sign-On
Because Keycloak is designed for enterprise environments, it integrates perfectly into a modern Docker-based architecture.
ποΈ My Authentication Architecture
One design decision is especially important:
Angular never communicates directly with Keycloak.
Instead, the complete authentication flow is managed by the backend.
Authentication Flow π Browser β¬οΈ π °οΈ Angular β¬οΈ β Spring Boot β¬οΈ π Keycloak β¬οΈ π« JWT Token β¬οΈ β Spring Boot β¬οΈ π °οΈ Angular |
This approach keeps every security-sensitive operation on the server.
The frontend never needs to know how authentication actually works.
βοΈ Why I Prefer This Architecture
For me, this architecture offers several important advantages.
π Better Security
The frontend never talks directly to the identity provider.
All authentication logic remains inside the backend.
π― Centralized Authentication
Spring Boot controls the complete login process.
This creates a single place where authentication and authorization can be managed consistently.
π§Ή Cleaner Frontend
Angular only focuses on presenting the user interface.
Authentication logic stays out of the client application.
π Easier Maintenance
Because responsibilities are clearly separated, every component can evolve independently without affecting the rest of the platform.
π§© Clear Responsibilities
Every technology in the platform has exactly one responsibility.
Component | Responsibility |
π °οΈ Angular | User Interface |
β Spring Boot | Business Logic |
π Keycloak | Authentication & Authorization |
ποΈ PostgreSQL | Application Data |
π Contentful | Content Management |
π³ Docker | Container Platform |
βοΈ Jenkins | CI/CD Pipeline |
This separation makes the overall architecture easier to understand, test, and maintain.
π± Built to Scale
One of my main goals was creating a platform that can grow over time.
Instead of coupling every feature together, each component has a clearly defined responsibility.
That makes it much easier to introduce new services, extend existing functionality, or replace individual technologies without redesigning the entire application.
π‘ Why Open Source Matters
Another reason for choosing Keycloak is the open-source ecosystem.
It is actively maintained, well documented, and widely adopted in enterprise environments.
Using proven open-source technologies allows me to focus on innovation instead of rebuilding existing solutions.
π¬ Related Video
In this video, I explain why I chose Keycloak for authentication and authorization in my platform. You'll see how it integrates with Spring Boot and Angular, why the backend manages the authentication flow, and how this architecture creates a secure, scalable, and maintainable foundation for modern web applications.
π― Conclusion
Keycloak has become a central part of my software architecture.
Combined with Spring Boot, Angular, PostgreSQL, Contentful, Docker, and Jenkins, it creates a modern platform where every component has a clear responsibility.
Rather than spending time building authentication from scratch, I can focus on what really matters:
π Developing new features
π Creating valuable content
π Keeping the platform secure
π Building a scalable architecture for the future
To me, that's what modern software engineering is all aboutβchoosing the right tools, defining clear responsibilities, and building systems that are designed to evolve.
