Spring Boot | Keycloak | REST API
Implementing and Securing a Simple Spring Boot REST API using Keycloak for IAM
Step-by-step guide on implementing and securing Simple API application using Keycloak for Identity and Access Management
Published in
8 min readApr 22, 2023
In this article, we will implement a Simple Spring Boot API, called Simple API, securing it and use Keycloak as Identity and Access Management (IAM) solution. As the name already suggests, the application is very simple and just contains two endpoints, /public
and /secured
.
Let’s get started!
Prerequisites
If you would like to follow along, you must have Java 17+ and Docker installed on your machine.
Starting Keycloak
Let’s run a Keycloak Docker container by executing the following command in a terminal:
docker run --rm --name keycloak \
-p 9080:8080 \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:24.0.2 start-dev
Configuring Keycloak
Sign in
- Open a browser and access Keycloak Web Console at http://localhost:9080;