r/SpringBoot • u/Lordion95 • 6h ago
Question how do you guys actually structure a react + spring boot + keycloak setup for serious projects?
yo, i'm trying to build a full-stack app using react on the frontend, spring boot for the backend, and keycloak handling auth, and i kinda need some guidance on how to do it properly instead of just hacking together a basic tutorial setup.
right now i get the general idea of spinning up keycloak and getting a basic login working, but i'm a bit lost on the best practices for real/bigger projects and where to go from here. specifically:
how are you guys handling tokens on the react side? is storing them in memory/using a BFF (backend for frontend) pattern the move nowadays, or is standard
keycloak-js/react-oidc-contextstill fine?on the spring boot side, how do you cleanly sync keycloak users with your own database (like storing extra user profile info, orders, etc.)? do you just use the
subclaim from the jwt on every request, use keycloak event listeners, or something else?what's the best way to handle roles and permissions across both frontend routes and spring security endpoints without it turning into a mess?
i asked opencode a bit about how spring boot 4.1 and spring security 7 handles this today, it has like their own prefix config on application.yaml or which is the right way to setup the JWT converter (the role mapping one) since I've tried and it doesnt quite work..?
if anyone has a solid repo structure, workflow, or just tips on how to build out from a basic "hello world" auth setup into an actual production-ready app, i'd really appreciate it. thanks!