# Easily secure your Spring Boot applications with Keycloak

DevFeed: [Easily secure your Spring Boot applications with Keycloak](<https://devfeed.tech/articles/easily-secure-your-spring-boot-applications-with-keycloak-31564.md>)

Original publisher: [Read original article](<https://www.keycloak.org/2017/05/easily-secure-your-spring-boot>)

Author: Sébastien Blanc

Published: 2017-05-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [Keycloak Blog](<https://devfeed.tech/sources/keycloak-blog.md>)

Topics: [Keycloak](<https://devfeed.tech/topics/keycloak.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Authorization](<https://devfeed.tech/topics/authorization.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [LDAP](<https://devfeed.tech/topics/ldap.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [backend](<https://devfeed.tech/tags/backend.md>), [identity-management](<https://devfeed.tech/tags/identity-management.md>), [idm](<https://devfeed.tech/tags/idm.md>), [kerberos](<https://devfeed.tech/tags/kerberos.md>), [keycloak](<https://devfeed.tech/tags/keycloak.md>), [ldap](<https://devfeed.tech/tags/ldap.md>), [openid-connect](<https://devfeed.tech/tags/openid-connect.md>), [saml](<https://devfeed.tech/tags/saml.md>), [spring-boot](<https://devfeed.tech/tags/spring-boot.md>), [sso](<https://devfeed.tech/tags/sso.md>), [web-app](<https://devfeed.tech/tags/web-app.md>)

## AI overview

A tutorial showing how to secure Spring Boot applications with Keycloak. It explains Keycloak's authentication, authorization, and identity-management capabilities, then walks through setting up a server, creating a realm, configuring a client, and defining a role and user.

## Source excerpt

What is Keycloak? Although security is a crucial aspect of any application, its implementation can be difficult. Worse, it is often neglected, poorly implemented and intrusive in the code. But lately, security servers have appeared which allow for outsourcing and delegating all the authentication and authorization aspects. Of these servers, one of the most promising is Keycloak, open-source, flexible, and agnostic of any technology, it is easily deployable/adaptable in its own infrastructure. Moreover, Keycloak is more than just an authentication server, it also provides a complete Identity Management system, user federation for third parties like LDAP and a lot more ... Check it out on here. The project can also be found on Github Spring Boot and Keycloak Keycloak provides adapters for an application that needs to interact with a Keycloak instance. There are adapters for WildFly/EAP, NodeJS, Javascript and of course for Spring Boot. Setting up a Keycloak server You have different options to set up a Keycloak server but the easiest one is probably to grab a standalone distribution, unzip it and voila! Open a terminal and go to your unzipped Keycloak server and from the bin directory simply run: ./standalone.sh(bat) Then open a browser and go to http://localhost:8080/auth. Since it's the first time that the server runs you will have to create an admin user, so let's create an admin user with admin as username and admin for the password: Now you can log in into your administration console and start configuring Keycloak. Creating a new Realm Keycloak defines the concept of a realm in which you will define your clients, which in Keycloak terminology means an application that will be secured by Keycloak, it can be a Web App, a Java EE backend, a Spring Boot etc. So let's create a new realm by simply clicking the "Add realm" button: Let's call it "SpringBoot". Creating the client, the role, and the user Now we need to define a client, which will be our Spring Boot app. Go