Skip to content

Spring Boot 3, Spring Security, and Keycloak integration

Notifications You must be signed in to change notification settings

lunf/spring-3-keycloak

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot 3, Spring Security, and Keycloak

Purpose

A sample java code to demonstrate a Spring Boot 3 integration with Keycloak 17. It utilize Keycloak login page, and fetch a user's attribute based on Keycloak user profile.

Version

  • Spring Boot 3.0.4
  • Keycloak 23
  • Red Hat OpenJDK 17
  • Grafana
  • Prometheus

Screenshots

Keycloak User Profile

User Profile

JSON Response reading Keycloak Profile

JSON


Blog Post

Explanation of this code can be seen on below Red Hat Developer article,

https://developers.redhat.com/articles/2023/07/24/how-integrate-spring-boot-3-spring-security-and-keycloak

Keycloak with PostgreSQL, which includes Keycloak's monitoring using Prometheus and Grafana

  1. Requires docker and compose
  2. Parameterized using variables in the .env file
  3. Up the project using command:
docker compose up -d
App Port Username Password
Keycloak 8080 admin keycloak
Prometheus 9090
Grafana 3000 admin grafana
Gitlab 8084 root brIyDjJaiZvEwxH43nOMZvd379vbbd/LMkKxkAsmd+U=
Useful commands Discription
docker stats Containers resource usage (--no-stream only pull the first result)
docker compose logs Shows logs of containers (-f to follow logs)
docker compose down Stop and remove containers (-v remove named volumes declared in the volumes section of the Compose file and anonymous volumes attached to containers)
docker system prune -a -f Remove all unused containers, networks, images (--volumes prune volumes)
docker exec -it gitlab-ce grep 'Password:' /etc/gitlab/initial_root_password Find Gitlab root user
`export DOCKERHOST=$(ifconfig grep -E "([0-9]{1,3}.){3}[0-9]{1,3}"

Disclaimer

This code is provided "as is" without any guarantee whatsoever. 
Feel free to fork, add, remove, change, or do whatever you want with it. 

About

Spring Boot 3, Spring Security, and Keycloak integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 45.1%
  • Java 29.8%
  • JavaScript 17.3%
  • CSS 3.9%
  • Ruby 2.3%
  • D 1.6%