Feature Request: HTTP-Only Cookie Option for Refresh Tokens #44449
thabetwaleed
started this conversation in
Ideas
Replies: 2 comments
-
|
Keycloak implements OAuth2 according to RFC6749 which mandates that the refresh token is in the body, see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
If you want no tokens in the browser you need to build a backend for frontend (BFF). It handles login, stores the access and refresh token and enhances API requests running through this proxy. Example of such projects: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
Currently, Keycloak returns refresh tokens in the response body, which exposes them to JavaScript and makes them vulnerable to XSS attacks. Many modern web applications require storing refresh tokens in HTTP-Only cookies for enhanced security.
Proposed Solution
Add a client-level or realm-level configuration option to store refresh tokens in HTTP-Only cookies instead of the response body.
Configuration Options
Option 1: Client Setting
Clients → [Client Name] → Settings → Advanced
☑ Store Refresh Token in HTTP-Only Cookie
Option 2: Realm Setting
Realm Settings → Tokens
☑ Use HTTP-Only Cookies for Refresh Tokens (Global)
Expected Behavior
When enabled:
Security Benefits
Use Cases
Beta Was this translation helpful? Give feedback.
All reactions