r/SpringBoot
•
u/utsab-dahal
•
Jun 01 '26
•
1
Question First time using Keycloak with Spring Boot — confused about JWT vs DB sync (need guidance + examples)
Hi everyone,
I’m a beginner working on my first project using Spring Boot + Keycloak, and I’m a bit confused about the correct architecture. Any suggestions, video links, or GitHub project examples would be really helpful
What I understand so far:
- Keycloak handles authentication (login, registration, roles)
- Spring Boot acts as a resource server and validates JWT tokens
- My app has its own database for business logic (users, orders, etc.)
My confusion:
User data during registration
If a user registers in Keycloak, how should I handle extra fields like:
- phone number
- address
- app-specific profile data
What I’m looking for:
Since this is my first time using Keycloak, any of the following would really help:
- Best practice explanation
- Real-world architecture examples
- GitHub repos using Spring Boot + Keycloak properly
- YouTube videos or tutorials that actually follow production patterns
Thanks in advance
View all comments
Show parent comment
2
u/pitza__ Jun 01 '26 edited Jun 01 '26
I think it’s better in an http only cookie, that way it won’t be accessible via js.
It’s not baaad if you use localstorage, if your app is hit with an XSS vuln the attacker can still do http calls on the behalf of the user even with using cookies.
Nothing is secure on the client, that’s why it’s better to have short lived tokens + do not put any sensitive data in jwt claims.
I might be wrong tho lol.