You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: enforce secure refresh token delivery and update documentation
- Remove support for refresh tokens sent via query parameters to improve security and prevent token leakage
- Update documentation and code comments to clarify that refresh tokens should only be delivered via cookies, JSON body, or form data
- Adjust tests to ensure query parameters containing refresh tokens are ignored and do not take precedence over secure delivery methods
- Add explicit security notice to documentation explaining risks of query parameter usage for token transmission
Signed-off-by: appleboy <[email protected]>
http -v --json POST localhost:8000/login username=admin password=admin
1243
1243
1244
-
# Method 1: Use refresh token from response (manual)
1245
-
http -v --form POST localhost:8000/refresh refresh_token=your_refresh_token_here
1246
-
1247
-
# Method 2: With cookies enabled (automatic - recommended for browsers)
1244
+
# Method 1: With cookies enabled (automatic - recommended for browsers)
1248
1245
# The refresh token cookie is automatically sent, no need to manually include it
1249
1246
http -v POST localhost:8000/refresh --session=./session.json
1250
1247
1251
-
# Method 3: Send refresh token in JSON body
1248
+
# Method 2: Send refresh token in JSON body
1252
1249
http -v --json POST localhost:8000/refresh refresh_token=your_refresh_token_here
1253
1250
1254
-
# Method 4: Send refresh token as query parameter
1255
-
http -v POST localhost:8000/refresh?refresh_token=your_refresh_token_here
1251
+
# Method 3: Use refresh token from response via form data
1252
+
http -v --form POST localhost:8000/refreshrefresh_token=your_refresh_token_here
1256
1253
```
1257
1254
1258
-
**Note**: When `SendCookie` is enabled, refresh tokens are automatically stored in httpOnly cookies. Browser-based applications can simply call the refresh endpoint without manually including the token - it's handled automatically by the cookie mechanism.
1255
+
**Security Note**: When `SendCookie` is enabled, refresh tokens are automatically stored in httpOnly cookies. Browser-based applications can simply call the refresh endpoint without manually including the token - it's handled automatically by the cookie mechanism.
1256
+
1257
+
**Important**: Query parameters are NOT supported for refresh tokens as they expose tokens in server logs, proxy logs, browser history, and Referer headers. Use cookies (recommended), JSON body, or form data instead.
1259
1258
1260
1259

1261
1260
@@ -1664,8 +1663,9 @@ This is a provided function to be called on any refresh token endpoint. The hand
1664
1663
1665
1664
1.**Cookie** (most common for browser-based apps): `RefreshTokenCookieName` cookie (default: `"refresh_token"`)
4.**JSON Body**: `refresh_token` field in request body
1666
+
3.**JSON Body**: `refresh_token` field in request body
1667
+
1668
+
**Security Note**: Query parameters are NOT supported for refresh tokens to prevent token leakage through server logs, proxy logs, browser history, and Referer headers. Only secure delivery methods are supported.
1669
1669
1670
1670
If the refresh token is valid and not expired, the handler will:
1671
1671
@@ -1674,7 +1674,7 @@ If the refresh token is valid and not expired, the handler will:
1674
1674
- Set both tokens as cookies (if `SendCookie` is enabled)
1675
1675
- Pass the new tokens into `RefreshResponse`
1676
1676
1677
-
This follows OAuth 2.0 security best practices by rotating refresh tokens and supporting multiple delivery methods.
1677
+
This follows OAuth 2.0 security best practices by rotating refresh tokens and supporting multiple secure delivery methods.
1678
1678
1679
1679
**Cookie-Based Authentication**: When using cookies (recommended for browser apps), the refresh token is automatically sent with the request, so you don't need to manually include it. Simply call the refresh endpoint and the middleware handles everything.
0 commit comments