Need advice about which tool to choose?Ask the StackShare community!
Keycloak vs Spring Security: What are the differences?
Keycloak and Spring Security are two popular security frameworks used in building secure applications. Here are the key differences between Keycloak and Spring Security:
Authentication and Authorization: Keycloak is a standalone IAM solution offering centralized authentication and authorization services, including SSO and social login. Spring Security is a flexible security framework integrated into the Spring ecosystem, allowing developers to define authentication and authorization rules within their application code.
Single Sign-On (SSO) and Federation: Keycloak excels in providing SSO capabilities out of the box. It supports various protocols like OpenID Connect, OAuth, and SAML for federated identity management, enabling users to authenticate once and access multiple applications seamlessly. Keycloak acts as an identity broker, allowing users to authenticate against different identity providers. Spring Security, on the other hand, can integrate with SSO solutions like Keycloak and leverage its capabilities for SSO and federation. Spring Security provides a pluggable architecture that allows developers to integrate with various identity providers and implement SSO functionality.
User Management and Administration: Keycloak offers a comprehensive user management and administration interface. It provides features like user registration, password reset, user groups, role-based access control, and fine-grained permission management. Keycloak's administration console allows administrators to manage users, roles, and policies centrally. Spring Security, on the other hand, does not provide a built-in user management interface. Developers using Spring Security need to implement user management and administration features themselves or integrate with external user management systems.
Integration with Ecosystem: Keycloak is a standalone IAM solution and can be used with any application stack. It provides client libraries and SDKs for various programming languages and frameworks. Keycloak integrates well with Java-based applications and frameworks, including Spring. On the other hand, Spring Security is tightly integrated with the Spring ecosystem, making it a natural choice for developers working with Spring-based applications. Spring Security provides seamless integration with other Spring modules, such as Spring MVC, Spring Boot, and Spring Data.
In summary, Keycloak is a standalone IAM solution that offers centralized authentication, authorization, and SSO capabilities. It provides a comprehensive user management and administration interface. Spring Security, on the other hand, is a security framework integrated into the Spring ecosystem, offering flexible security infrastructure and seamless integration with Spring-based applications. It allows developers to define authentication and authorization rules within their application code.
I am working on building a platform in my company that will provide a single sign on to all of the internal products to the customer. To do that we need to build an Authorisation server to comply with the OIDC protocol. Earlier we had built the Auth server using the Spring Security OAuth project but since in Spring Security 5.x it is no longer supported we are planning to get over with it as well. Below are the 2 options that I was considering to replace the Spring Auth Server. 1. Keycloak 2. Okta 3. Auth0 Please advise which one to use.
It isn't clear if beside the AuthZ requirement you had others, but given the scenario you described my suggestion would for you to go with Keycloak. First of all because you have already an onpremise IdP and with Keycloak you could maintain that setup (if privacy is a concern). Another important point is configuration and customization: I would assume with Spring OAuth you might have had some custom logic around authentication, this can be easily reconfigured in Keycloak by leveraging SPI (https://www.keycloak.org/docs/latest/server_development/index.html#_auth_spi). Finally AuthZ as a functionality is well developed, based on standard protocols and extensible on Keycloak (https://www.keycloak.org/docs/latest/authorization_services/)
You can also use Keycloak as an Identity Broker, which enables you to handle authentication on many different identity providers of your customers. With this setup, you are able to perform authorization tasks centralized.
We have good experience using Keycloak for SSO with OIDC with our Spring Boot based applications. It's free, easy to install and configure, extensible - so I recommend it.
Pros of Keycloak
- It's a open source solution33
- Supports multiple identity provider24
- OpenID and SAML support17
- Easy customisation12
- JSON web token10
- Maintained by devs at Redhat6
Pros of Spring Security
- Easy to use3
- Java integration3
Sign up to add or upvote prosMake informed product decisions
Cons of Keycloak
- Okta7
- Poor client side documentation6
- Lack of Code examples for client side5