Skip to content

Commit 7cbcd0b

Browse files
authored
Merge pull request #443 from dhensby/docs/model-typedef-fixes
docs: fix incorrect model typedefs (AuthorizationCodeData / ClientData)
2 parents 17d9230 + e639374 commit 7cbcd0b

6 files changed

Lines changed: 60 additions & 6 deletions

File tree

docs/api/grant-types/authorization-code-grant-type.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [new AuthorizationCodeGrantType(options)](#new_AuthorizationCodeGrantType_new)
88
* [.handle(request, client)](#AuthorizationCodeGrantType+handle)
99
* [.getAuthorizationCode(request, client)](#AuthorizationCodeGrantType+getAuthorizationCode) ⇒ <code>Promise.&lt;{user}&gt;</code>
10+
* [.verifyPKCE(request, code)](#AuthorizationCodeGrantType+verifyPKCE)
1011
* [.validateRedirectUri(request, code)](#AuthorizationCodeGrantType+validateRedirectUri)
1112
* [.revokeAuthorizationCode(code)](#AuthorizationCodeGrantType+revokeAuthorizationCode)
1213
* [.saveToken(user, client, authorizationCode, requestedScope)](#AuthorizationCodeGrantType+saveToken)
@@ -44,6 +45,23 @@ Get the authorization code.
4445
| request | <code>Request</code> |
4546
| client | <code>ClientData</code> |
4647

48+
<a name="AuthorizationCodeGrantType+verifyPKCE"></a>
49+
50+
### authorizationCodeGrantType.verifyPKCE(request, code)
51+
Verify PKCE code_verifier against the stored code_challenge.
52+
53+
This is called from handle() AFTER the authorization code has been
54+
revoked, so that a failed verification attempt consumes the code
55+
and prevents online brute-force guessing.
56+
57+
**Kind**: instance method of [<code>AuthorizationCodeGrantType</code>](#AuthorizationCodeGrantType)
58+
**See**: https://datatracker.ietf.org/doc/html/rfc7636#section-4.6
59+
60+
| Param | Type |
61+
| --- | --- |
62+
| request | <code>Request</code> |
63+
| code | <code>AuthorizationCodeData</code> |
64+
4765
<a name="AuthorizationCodeGrantType+validateRedirectUri"></a>
4866

4967
### authorizationCodeGrantType.validateRedirectUri(request, code)

docs/api/handlers/authorize-handler.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,20 @@ Update response with the redirect uri and the state parameter, if available.
125125
<a name="AuthorizeHandler+getCodeChallengeMethod"></a>
126126

127127
### authorizeHandler.getCodeChallengeMethod()
128-
Get code challenge method from request or defaults to plain.
129-
https://www.rfc-editor.org/rfc/rfc7636#section-4.3
128+
Get code challenge method from request.
129+
130+
When `enablePlainPKCE` is false (the default), the "plain" method is
131+
rejected and the default (when no method is provided) is "S256".
132+
When `enablePlainPKCE` is true, "plain" is accepted and used as the
133+
default per RFC 7636 §4.3.
130134

131135
**Kind**: instance method of [<code>AuthorizeHandler</code>](#AuthorizeHandler)
132136
**Throws**:
133137

134138
- <code>InvalidRequestError</code> if request contains unsupported code_challenge_method
135139
(see https://www.rfc-editor.org/rfc/rfc7636#section-4.4)
136140

141+
**See**: https://www.rfc-editor.org/rfc/rfc7636#section-4.3
137142
<a name="responseTypes"></a>
138143

139144
## responseTypes

docs/api/model.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ An `Object` representing the authorization code and associated data. `code.clien
657657

658658
| Name | Type | Description |
659659
| --- | --- | --- |
660-
| code | <code>string</code> | The authorization code passed to `getAuthorizationCode()`. |
660+
| authorizationCode | <code>string</code> | The authorization code passed to `getAuthorizationCode()`. |
661661
| expiresAt | <code>Date</code> | The expiry time of the authorization code. |
662662
| redirectUri | <code>string</code> | The redirect URI of the authorization code. |
663663
| scope | <code>Array.&lt;string&gt;</code> | The authorized scope of the authorization code. |
@@ -674,7 +674,7 @@ An `Object` representing the client and associated data.
674674

675675
| Name | Type | Description |
676676
| --- | --- | --- |
677-
| id | <code>string</code> | The authorization code passed to `getAuthorizationCode()`. |
677+
| id | <code>string</code> | A unique string identifying the client. |
678678
| redirectUris | <code>Array.&lt;string&gt;</code> | Redirect URIs allowed for the client. Required for the `authorization_code` grant. |
679679
| grants | <code>Array.&lt;string&gt;</code> | Grant types allowed for the client. |
680680
| accessTokenLifetime | <code>number</code> | Client-specific lifetime of generated access tokens in seconds. |

docs/api/pkce/pkce.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## Modules
2+
3+
<dl>
4+
<dt><a href="#module_pkce">pkce</a></dt>
5+
<dd></dd>
6+
</dl>
7+
8+
## Constants
9+
10+
<dl>
11+
<dt><a href="#codeChallengeAndVerifierRegexp">codeChallengeAndVerifierRegexp</a> : <code>RegExp</code></dt>
12+
<dd><p>ABNF for &quot;code_verifier&quot; and &quot;code_challenge&quot; is as follows.</p>
13+
<p>code-verifier = 43*128unreserved
14+
unreserved = ALPHA / DIGIT / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;
15+
ALPHA = %x41-5A / %x61-7A
16+
DIGIT = %x30-39</p>
17+
</dd>
18+
</dl>
19+
120
<a name="module_pkce"></a>
221

322
## pkce
@@ -62,3 +81,14 @@ Checks if the code challenge method is one of the supported methods
6281
| --- | --- |
6382
| method | <code>String</code> |
6483

84+
<a name="codeChallengeAndVerifierRegexp"></a>
85+
86+
## codeChallengeAndVerifierRegexp : <code>RegExp</code>
87+
ABNF for "code_verifier" and "code_challenge" is as follows.
88+
89+
code-verifier = 43*128unreserved
90+
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
91+
ALPHA = %x41-5A / %x61-7A
92+
DIGIT = %x30-39
93+
94+
**Kind**: global constant

docs/api/server.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Instantiates `OAuth2Server` using the supplied model.
4343
| [options.requireClientAuthentication] | <code>object</code> \| <code>boolean</code> | <code>object</code> | Require a client secret for grant types (names as keys). Defaults to `true` for all grant types. |
4444
| [options.alwaysIssueNewRefreshToken] | <code>boolean</code> | <code>true</code> | Always revoke the used refresh token and issue a new one for the `refresh_token` grant. |
4545
| [options.extendedGrantTypes] | <code>object</code> | <code>object</code> | Additional supported grant types. |
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. |
4647

4748
**Example**
4849
```js

lib/model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const ServerError = require('./errors/server-error');
2929
/**
3030
* @typedef AuthorizationCodeData
3131
* @description An `Object` representing the authorization code and associated data. `code.client` and `code.user` can carry additional properties that will be ignored by *oauth2-server*.
32-
* @property code {string} The authorization code passed to `getAuthorizationCode()`.
32+
* @property authorizationCode {string} The authorization code passed to `getAuthorizationCode()`.
3333
* @property expiresAt {Date} The expiry time of the authorization code.
3434
* @property redirectUri {string} The redirect URI of the authorization code.
3535
* @property scope {string[]} The authorized scope of the authorization code.
@@ -41,7 +41,7 @@ const ServerError = require('./errors/server-error');
4141
* @typedef ClientData
4242
* @alias ClientData
4343
* @description An `Object` representing the client and associated data.
44-
* @property id {string} The authorization code passed to `getAuthorizationCode()`.
44+
* @property id {string} A unique string identifying the client.
4545
* @property redirectUris {string[]} Redirect URIs allowed for the client. Required for the `authorization_code` grant.
4646
* @property grants {string[]} Grant types allowed for the client.
4747
* @property accessTokenLifetime {number} Client-specific lifetime of generated access tokens in seconds.

0 commit comments

Comments
 (0)