Securing Spring Boot REST APIs with Keycloak

Dinuth De Zoysa
DevOps Dudes
Published in
12 min readApr 24, 2020

--

Overview

Keycloak is an open-source identity and access management solution which makes it easy to secure modern applications and services with little to no code.

Keycloak comes with its own adapters for selected platforms, but it is also possible to use generic OpenID Connect Relying Party and SAML Service Provider libraries. But using the Keycloak Client Adaptors would be much simpler, easy to use and they require less boilerplate code than what is typically required by a library.

The primary focus of this article is to secure Spring Boot REST APIs with Keycloak Spring Boot Adaptor.

To follow through this tutorial, you need to have a running Keycloak instance. If you don’t have, follow my previous Medium article.

Keycloak for Identity and Access Management & High Availability Deployment with Kubernetes

Keycloak Configuration

First, let’s make the required configurations in Keycloak.

Create Realm

A Realm manages a set of users, credentials, roles, and groups. A user belongs to and logs into a realm. Realms are isolated from one another and can only manage and authenticate the…

--

--

Dinuth De Zoysa
DevOps Dudes

Technology evangelist, Software Architect, Cloud Architect with many years spent designing world class mission critical software.