-
I'm designing a solution for authentication with Keycloak for an existing set of microservices. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@ASarco this is an interesting question (and you obviously have thought about it already).
Actually it would be sending the encrypted tokens in a cookie (access, refresh and ID tokens). That's:
To me, it is:
Sure, keeping state on the server is not ideal. I know at least two options for an impl, but both have drawbacks:
At the end of the day, I prefer to keep tokens on the server because neither of this drawbacks seems to be a real show-stopper: the latences we are talking about are really low and the server memory needed to store tokens in session is acceptable. Please note that I haven't run any benchmark to mesure the actual impact of each solution (latency with Spring Session, latency after an instance crash with smart proxy, latency and network cost with encrypted tokens stored in cookies). |
Beta Was this translation helpful? Give feedback.
-
@ch4mpy Thank you very much for taking the time to write such a detailed answer. It's very clear and really helpful. One more question, not directly related to this: In your Baeldung article about BFF and Spring Gateway, you show 2 separate boxes, the BFF with Spring-oauth2-client, and a reverse proxy with Spring gateway. Why are you using 2 boxes for this, instead of one with both things? |
Beta Was this translation helpful? Give feedback.
-
There is no need for the SPA assets to be served through the BFF, there is just a need for the two to share the same origin. Separating the reverse-proxy and the OAuth2 BFF has several advantages:
|
Beta Was this translation helpful? Give feedback.
@ASarco this is an interesting question (and you obviously have thought about it already).
Actually it would be sending the encrypted tokens in a cookie (access, refresh and ID tokens). That's:
To me, it is:
@Bean
based on cookies instead of session.