

Using Keycloak to authorize & authenticate Spring Boot application
source link: https://dev.to/datmt/using-keycloak-to-authorize-authenticate-spring-boot-application-4d9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.


Posted on Nov 21
Using Keycloak to authorize & authenticate Spring Boot application
Recently I started an SaaS project. For any project, one of the first problems you need to solve is authentication and authorization. It's 2021 and it's quite foolish to build your own system to log users in and check their role. After a few weeks study available options, I decided to go with Spring Boot & Keycloak.
If you don't know Keycloak, it's an opensource project that help you quickly setup authentication & authorization for your app. In my case, this is a perfect fit.
Project requirements
- App has three roles member, moderator, admin
- API must have endpoints to create user and let user login
- Endpoints authorization could be configure with path prefix (for example /admin...) or by developer specifies the role allowed for each endpoint (using @RolesAllowed)
The code
The project is available here on Github, you can checkout and try it right away:
https://github.com/datmt/Keycloak-Spring-Boot-Login-Create-User
Need tutorial?
If you need step by step tutorial, check my post here:
https://datmt.com/backend/integrate-keycloak-with-spring-boot-step-by-step/
Conclusion
Keycloak is a mature solution for authorization and authentication. It has quite many customization that can fit into various needs. If you can use it in your project, it can save you a great deal of valuable time.
Recommend
-
3
SPRING BOOT OAUTH2 + KEYCLOAK - service to service call employee-service调用department-service,如果要按OAUTH2.0流程,只需要提供client-id和client-sec...
-
8
Spring Boot, Security, PostgreSQL, and Keycloak REST API OAuth2 by Didin J., updated on Mar 07, 2022
-
5
Not FoundYou just hit a route that doesn't exist... the sadness.LoginRadius empowers businesses to deliver a delightful customer experience and win customer trust. Using the LoginRadius Identity...
-
10
Single sign-on is often implemented with Keycloak. Few people know that Keycloak can also implement single sign-out, where logging out from one application causes Keycloak to log the user out...
-
3
OAuth 2.0, OpenID Connect, Keycloak a Spring Boot ~/robonovotny
-
7
OAuth 2.0, OpenID Connect, Keycloak a Spring Boot ~/robonovotny
-
10
OAuth 2.0, OpenID Connect, Keycloak a Spring Boot 3 ~/robonovotny
-
6
Flow pre Authorization Code s PKCE pre verejných klientov ~/robonovotny ...
-
9
Spring Boot 3.1中如何整合Spring Security和Keycloak
-
9
Quite some time ago, Keycloak deprecated its adapters, including OpenID connect for Java adapt...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK