-
-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PKCE support #658
Open
jcdogo
wants to merge
2
commits into
oauthjs:dev
Choose a base branch
from
dogomedia:features/pkce
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add PKCE support #658
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -336,25 +336,29 @@ This model function is **required** if the ``authorization_code`` grant is used. | |||||
|
||||||
An ``Object`` representing the authorization code and associated data. | ||||||
|
||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+====================+========+==============================================================+ | ||||||
| code | Object | The return value. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| code.code | String | The authorization code passed to ``getAuthorizationCode()``. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| [code.redirectUri] | String | The redirect URI of the authorization code. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| code.client | Object | The client associated with the authorization code. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| code.client.id | String | A unique string identifying the client. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
| code.user | Object | The user associated with the authorization code. | | ||||||
+--------------------+--------+--------------------------------------------------------------+ | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+============================+========+===============================================================+ | ||||||
| code | Object | The return value. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.code | String | The authorization code passed to ``getAuthorizationCode()``. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| [code.redirectUri] | String | The redirect URI of the authorization code. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.client | Object | The client associated with the authorization code. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.client.id | String | A unique string identifying the client. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.user | Object | The user associated with the authorization code. | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
| [code.codeChallengeMethod] | String | The string for the code challenge method (`S256` or `plain`). | | ||||||
+----------------------------+--------+---------------------------------------------------------------+ | ||||||
|
||||||
``code.client`` and ``code.user`` can carry additional properties that will be ignored by *oauth2-server*. | ||||||
|
||||||
|
@@ -379,7 +383,9 @@ An ``Object`` representing the authorization code and associated data. | |||||
redirectUri: code.redirect_uri, | ||||||
scope: code.scope, | ||||||
client: client, // with 'id' property | ||||||
user: user | ||||||
user: user, | ||||||
codeChallenge: code.code_challenge, | ||||||
codeChallengeMethod: code.code_challenge_method | ||||||
}; | ||||||
}); | ||||||
} | ||||||
|
@@ -665,51 +671,59 @@ This model function is **required** if the ``authorization_code`` grant is used. | |||||
|
||||||
**Arguments:** | ||||||
|
||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+========================+==========+=====================================================================+ | ||||||
| code | Object | The code to be saved. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.authorizationCode | String | The authorization code to be saved. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.redirectUri | String | The redirect URI associated with the authorization code. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| client | Object | The client associated with the authorization code. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| user | Object | The user associated with the authorization code. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [callback] | Function | Node-style callback to be used instead of the returned ``Promise``. | | ||||||
+------------------------+----------+---------------------------------------------------------------------+ | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+============================+==========+=====================================================================+ | ||||||
| code | Object | The code to be saved. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.authorizationCode | String | The authorization code to be saved. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| code.redirectUri | String | The redirect URI associated with the authorization code. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [code.codeChallengeMethod] | String | The string for the code challenge method (`S256` or `plain`). | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| client | Object | The client associated with the authorization code. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| user | Object | The user associated with the authorization code. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
| [callback] | Function | Node-style callback to be used instead of the returned ``Promise``. | | ||||||
+----------------------------+----------+---------------------------------------------------------------------+ | ||||||
|
||||||
.. todo:: Is ``code.scope`` really optional? | ||||||
|
||||||
**Return value:** | ||||||
|
||||||
An ``Object`` representing the authorization code and associated data. | ||||||
|
||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+========================+========+===============================================================+ | ||||||
| code | Object | The return value. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.authorizationCode | String | The authorization code passed to ``saveAuthorizationCode()``. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.redirectUri | String | The redirect URI associated with the authorization code. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.client | Object | The client associated with the authorization code. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.client.id | String | A unique string identifying the client. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
| code.user | Object | The user associated with the authorization code. | | ||||||
+------------------------+--------+---------------------------------------------------------------+ | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| Name | Type | Description | | ||||||
+============================+========+================================================================+ | ||||||
| code | Object | The return value. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.authorizationCode | String | The authorization code passed to ``saveAuthorizationCode()``. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.expiresAt | Date | The expiry time of the authorization code. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.redirectUri | String | The redirect URI associated with the authorization code. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| [code.scope] | String | The authorized scope of the authorization code. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.client | Object | The client associated with the authorization code. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.client.id | String | A unique string identifying the client. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| code.user | Object | The user associated with the authorization code. | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). | | ||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
| [code.codeChallengeMethod] | String | The string for the code challenge method (`S256` or `plain` | | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
+----------------------------+--------+----------------------------------------------------------------+ | ||||||
|
||||||
``code.client`` and ``code.user`` can carry additional properties that will be ignored by *oauth2-server*. | ||||||
|
||||||
|
@@ -725,7 +739,9 @@ An ``Object`` representing the authorization code and associated data. | |||||
redirect_uri: code.redirectUri, | ||||||
scope: code.scope, | ||||||
client_id: client.id, | ||||||
user_id: user.id | ||||||
user_id: user.id, | ||||||
code_challenge: code.codeChallenge, | ||||||
code_challenge_method: code.codeChallengeMethod | ||||||
}; | ||||||
return db.saveAuthorizationCode(authCode) | ||||||
.then(function(authorizationCode) { | ||||||
|
@@ -735,7 +751,9 @@ An ``Object`` representing the authorization code and associated data. | |||||
redirectUri: authorizationCode.redirect_uri, | ||||||
scope: authorizationCode.scope, | ||||||
client: {id: authorizationCode.client_id}, | ||||||
user: {id: authorizationCode.user_id} | ||||||
user: {id: authorizationCode.user_id}, | ||||||
codeChallenge: authorizationCode.code_challenge, | ||||||
codeChallengeMethod: authorizationCode.code_challenge_method | ||||||
}; | ||||||
}); | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be typo,