I am developing a rest api in spring boot, in which i've integrated keycloak for handling user authentication and authorization. What happens is:
On the frontend application side, I make subsequent calls by exchanging cookies with the server (http-only, secure, samesite, etc). So the token is saved in the cookies and the cookie expiration follows the token expiration. Each request to spring boot validates the token backend-side.
In this case, the access token and the refresh token are stored in two cookies, in clear text in the user's browser, so an attacker can read and reuse the token while it is still valid... perhaps.
What is the best practice for hardening security in this regard? Does it make sense to return an encrypted token with a private key from the back end? What are the best practices to make the token, which is currently stored in clear text in browser cookies, even more secure?
Thank you
When I want to manage authentication via frontend web app, I pass user credentials in https to spring boot login endpoint
This looks like the OAuth2 password flow which was deprecated long ago and is removed from OAuth 2.1 for security reasons
What is the best practice for hardening security in this regard?