Skip to content

Commit

Permalink
fix: memory adapter grant references for intended models
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jul 19, 2021
1 parent 9f759e0 commit 2fe4dc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 8 additions & 6 deletions example/my_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class MyAdapter {
* @constructor
* @param {string} name Name of the oidc-provider model. One of "Grant, "Session", "AccessToken",
* "AuthorizationCode", "RefreshToken", "ClientCredentials", "Client", "InitialAccessToken",
* "RegistrationAccessToken", "DeviceCode", "Interaction", "ReplayDetection", or "PushedAuthorizationRequest"
* "RegistrationAccessToken", "DeviceCode", "Interaction", "ReplayDetection",
* "BackchannelAuthenticationRequest", or "PushedAuthorizationRequest"
*
*/
constructor(name) {
Expand Down Expand Up @@ -71,15 +72,16 @@ class MyAdapter {
* - gty {string} - [AccessToken, RefreshToken only] space delimited grant values, indicating
* the grant type(s) they originate from (implicit, authorization_code, refresh_token or
* device_code) the original one is always first, second is refresh_token if refreshed
* - params {object} - [DeviceCode only] an object with the authorization request parameters
* as requested by the client with device_authorization_endpoint
* - params {object} - [DeviceCode and BackchannelAuthenticationRequest only] an object with the
* authorization request parameters as requested by the client with device_authorization_endpoint
* - userCode {string} - [DeviceCode only] user code value
* - deviceInfo {object} - [DeviceCode only] an object with details about the
* device_authorization_endpoint request
* - inFlight {boolean} - [DeviceCode only]
* - error {string} - [DeviceCode only] - error from authnz to be returned to the polling client
* - errorDescription {string} - [DeviceCode only] - error_description from authnz to be returned
* to the polling client
* - error {string} - [DeviceCode and BackchannelAuthenticationRequest only] - error from authnz to be
* returned to the polling client
* - errorDescription {string} - [DeviceCode and BackchannelAuthenticationRequest only] - error_description
* from authnz to be returned to the polling client
* - policies {string[]} - [InitialAccessToken, RegistrationAccessToken only] array of policies
* - request {string} - [PushedAuthorizationRequest only] Pushed Request Object value
*
Expand Down
10 changes: 9 additions & 1 deletion lib/adapters/memory_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ function userCodeKeyFor(userCode) {
return `userCode:${userCode}`;
}

const grantable = new Set([
'AccessToken',
'AuthorizationCode',
'RefreshToken',
'DeviceCode',
'BackchannelAuthenticationRequest',
]);

class MemoryAdapter {
constructor(model) {
this.model = model;
Expand Down Expand Up @@ -56,7 +64,7 @@ class MemoryAdapter {
}

const { grantId, userCode } = payload;
if (grantId) {
if (grantable.has(this.name) && grantId) {
const grantKey = grantKeyFor(grantId);
const grant = storage.get(grantKey);
if (!grant) {
Expand Down

0 comments on commit 2fe4dc8

Please sign in to comment.