This is the last blog of the series of securing spring boot application with keycloak. It is recommended to go through this first blog and second blog here.
In last blog post of this series we saw how we can configure keycloak for our application. Now in this tutorial we will see how we can use keycloak with spring boot.
Prerequisite
Docker Keycloak Version
Spring Boo: 1.5.17.RELEASE Java: 1.
Setup Realm and clients in keycloak
This blog is the second part of the series of security spring boot application with keycloak. In first part we install setup in keycloak with docker you can see first part here
Version:
Keycloak: 4.5.0.Final Pre-requisites Keycloak should be installed in the Create realm A realm secures and manages security metadata for a set of users, applications, and registered oauth clients. Users can be created within a specific realm within the Administration console.
Introduction of Keycloak
Open Source Identity and Access Management For Modern Applications and Services. It add authentication to applications and secure services with minimum fuss. No need to deal with storing users or authenticating users. It’s all available out of the box.
You’ll even get advanced features such as User Federation, Identity Brokering and Social Login.
Prerequisites:
Docker: Since we are using Docker to install Keycloak; it should be installed on your machine.
Introduction
In this article we will see example of how to secure a spring boot rest application with Spring Boot2, Spring Security, Oauth2, and JWT token.
1. Source Code Repository
The code used in this article is available in this repository GitHub.
2. Dependencies
2.1. Versions
Spring Boot: 2.1.3.RELEASE Java: 1.8 3. Entity Class
We create two Entity Classes, one is User and another is Role. User entity class contains user details like name, password, roles details, and role entity contains the role details.