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
feat: add requirePKCE option to enforce PKCE on the authorization code grant
OAuth 2.1 and RFC 9700 (Security BCP) §2.1.1 require/recommend PKCE for all
authorization code flows; previously PKCE was opt-in per request.
When `requirePKCE` is enabled (default `false`):
- the authorize endpoint rejects requests without a `code_challenge`
(InvalidRequestError), so no PKCE-less authorization codes are issued; and
- the token endpoint rejects authorization codes issued without a
`code_challenge` (InvalidGrantError), closing the gap for pre-existing codes.
Plumbed through the server to the authorize and token handlers (mirroring
`enablePlainPKCE`), documented in JSDoc/typings, and covered by compliance
tests. Existing behaviour is unchanged when the option is off.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/api/server.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ Instantiates `OAuth2Server` using the supplied model.
44
44
|[options.alwaysIssueNewRefreshToken]| <code>boolean</code> | <code>true</code> | Always revoke the used refresh token and issue a new one for the `refresh_token` grant. |
45
45
|[options.extendedGrantTypes]| <code>object</code> | <code>object</code> | Additional supported grant types. |
46
46
|[options.enablePlainPKCE]| <code>boolean</code> | <code>false</code> | Allow the use of the `plain` code challenge method for PKCE. This is not recommended for production environments. |
47
+
|[options.requirePKCE]| <code>boolean</code> | <code>false</code> | Require PKCE for the `authorization_code` grant: `authorize` rejects requests without a `code_challenge`, and the token exchange rejects authorization codes that were issued without one. Recommended by OAuth 2.1. |
Copy file name to clipboardExpand all lines: lib/server.js
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,7 @@ class OAuth2Server {
45
45
* @param [options.alwaysIssueNewRefreshToken=true] {boolean=} Always revoke the used refresh token and issue a new one for the `refresh_token` grant.
46
46
* @param [options.extendedGrantTypes=object] {object} Additional supported grant types.
47
47
* @param [options.enablePlainPKCE=false] {boolean} Allow the use of the `plain` code challenge method for PKCE. This is not recommended for production environments.
48
+
* @param [options.requirePKCE=false] {boolean} Require PKCE for the `authorization_code` grant: `authorize` rejects requests without a `code_challenge`, and the token exchange rejects authorization codes that were issued without one. Recommended by OAuth 2.1.
48
49
*
49
50
* @throws {InvalidArgumentError} if the model is missing
50
51
* @return {OAuth2Server} A new `OAuth2Server` instance.
0 commit comments