DEV Community

Cover image for Keycloak and Spring Boot: The Ultimate Guide to Implementing Single Sign-On

Keycloak and Spring Boot: The Ultimate Guide to Implementing Single Sign-On

Tandap Noel Bansikah on October 30, 2024

Introduction: Single Sign-On (SSO) has become an essential feature in modern web applications, enhancing both user experience and securi...
Collapse
 
babry_galedou_2b2c0299dca profile image
Babry Galedou

Very good stuff. But i have an error here : localhost:8082/login/oauth2/code/k...

Collapse
 
bansikah profile image
Tandap Noel Bansikah • Edited

Thank you so much for your feedback @babry_galedou_2b2c0299dca I will look at that or we could have a session where we debug together

Collapse
 
babry_galedou_2b2c0299dca profile image
Babry Galedou

Okay, because not working for me

Thread Thread
 
bansikah profile image
Tandap Noel Bansikah

It’s fine Keycloak sometimes might be hard to configure if any issues then we will experience errors, so will it be cool to schedule a session with you let’s look at the configurations? Which day please we can continue here is my mail: tandapnoelbansikah@gmail.com

Thread Thread
 
babry_galedou_2b2c0299dca profile image
Babry Galedou

I'm new to it so little bit hard, no just when you have time I'm here not so busy

Thread Thread
 
bansikah profile image
Tandap Noel Bansikah

Ok that’s great I promise you we will fix it, today I was officially taking a vacation off from work and everything as soon as I get back we will work on it okay

Thread Thread
 
babry_galedou_2b2c0299dca profile image
Babry Galedou

Great, thank you

Collapse
 
jaydeep_kuber_8242d91fe8d profile image
Jaydeep Kuber

so this is a good stuff. but if i want to access it whith frontend
then whet i need to do ?

actul scenarion is, i have a frontentd , a gatewat and a rest api of spring and keycloak. frontend calls to gateway ok, gateway will proxy the url to the rest api and rest api will comminucate with KC for tockent auth. simple. till now all setup is local and runnig fine. but time to up on https, so i get self signed certificate by openssl which wroking fine with nginx, what nginx will do.... htts://frontend to frontend, same for gateway act as reverse proxy. frontend and gatway communicate properly. to avoide mixed content error i have to up KC behind the nginx proxy. but if i di this then my rest api and KC communication breaks. so

is there any way to up keycloak to listen both http and https,
Env: KC_HTTP_ENABLED: true this is current set up still not working,

thank you for time and cosideration.

Collapse
 
bansikah profile image
Tandap Noel Bansikah

@jaydeep_kuber_8242d91fe8d You can also visit this repository ping server application authentication with keycloak SSO to see the implementation in a fullstack spring boot and react application

Collapse
 
bansikah profile image
Tandap Noel Bansikah • Edited

Thank you very much @jaydeep_kuber_8242d91fe8d for your feedback sorry I didn’t see your message early enough we can look into your problem and possibly provide a demo for your use case and also maybe this could help seamless-authentication-system-int...

Collapse
 
moussa_diallo_0cbe613e453 profile image
Moussa Diallo

Now my concern is to be able to dockerize both the Keycloak service and the Spring Boot application. I’m struggling with the configurations to make sure both services can communicate properly internally and that the user is correctly redirected to Keycloak during authentication.

Collapse
 
bansikah profile image
Tandap Noel Bansikah

Thank you so much for your feedback @moussa_diallo_0cbe613e453 i think I handled that case in this application Ping sever application spring boot and react with with Keycloak as SSO . Wish to ask if you have a front end also please just have a look at that if it doesn’t help please let me know then we can have a call and I will see how to help. Thank you 😊