-
-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Specify your setup
- Operating System: Linux (Debian 12.12)
- Node version: 24.12.0
- npm version: N/A (using pnpm)
- version of @node-oauth/oauth2-server: 5.2.0
- which OAuth2 workflow: Refresh Token Grant (RFC 6749 Section 6)
- at which workflow step: Token refresh with scope parameter
Describe the bug
When refreshing a token with invalid scopes, the refresh token is revoked before scope validation. If validation fails, the token is destroyed without creating a replacement, permanently breaking authentication.
To Reproduce
- Issue refresh token without scope
- Client requests refresh with scope=some-scope
- revokeToken() destroys the token (line 57)
- getScope() throws InvalidScopeError (line 59)
- Client retries without scope
- Receives "Invalid grant: refresh token is invalid"
Expected behavior
Scope validation should occur before revocation. Invalid scope requests should fail without destroying the token.
Additional context
The fix is to swap lines 57 and 59 in lib/grant-types/refresh-token-grant-type.js to validate scope before revoking. Similar to issue #82 which addressed authorization code revocation timing.
jonahsnider
Metadata
Metadata
Assignees
Labels
No labels