/spring-keycloak-tutorials

A project sample to secure Spring Boot API with Keycloak :

Primary LanguageJava

Spring / Keycloak Tutorials

This is a sandbox / sample project to illustrate this blog article, part of our Keycloak series.

Technologies

  • Java 11
  • JUnit 5
  • Spring Boot 2.4.2
  • Keycloak 12.0.2

Pre-requisites

  • Start your Keycloak server before running the app

👉 How to install & start Keycloak

  • Create a demo realm working with this app
  • Create 2 users
    • One ineat-admin / password with ADMIN role associated
    • One ineat-user / password With USER role associated

How to start

  • For test :
mvn clean test
  • To run the app :
mvn spring-boot:run

How to test the Keycloak security

  • Use the provided postman_collection_v2.json
    • Generate an access_token thanks to the KEYCLOAK request TOKEN for USER or KEYCLOAK request TOKEN for ADMIN
    • Use this access_token as Bearer to call the protected /user or /admin endpoints thanks to the Request /user path or Request /admin path