Skip to content

Move validateScope outside promise.all #84

Closed

Description

@jorenvandeweyer

When there is an invalid scope passed, there is still an accessToken and refreshToken generated.

Code

PasswordGrantType.prototype.saveToken = function(user, client, scope) {
var fns = [
this.validateScope(user, client, scope),
this.generateAccessToken(client, user, scope),
this.generateRefreshToken(client, user, scope),
this.getAccessTokenExpiresAt(),
this.getRefreshTokenExpiresAt()
];
return Promise.all(fns)
.bind(this)
.spread(function(scope, accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt) {
var token = {
accessToken: accessToken,
accessTokenExpiresAt: accessTokenExpiresAt,
refreshToken: refreshToken,
refreshTokenExpiresAt: refreshTokenExpiresAt,
scope: scope
};
return promisify(this.model.saveToken, 3).call(this.model, token, client, user);
});
};

Suggestion

Move this.validateScope(user, client, scope) out of the array and check this before generating the tokens.

Use case

We use JWT's and only an internal token id is saved instead of the full JWT string. This means generating the token automatically means saving the token. So we are not actually using the saveToken function.

Activity

  1. jorenvandeweyer commented on Nov 23, 2021

    @jorenvandeweyer
    MemberAuthor

    It seems like some suggestions in #64 might fix this indirectly.

  2. added this to the v4.3 milestone on Aug 25, 2022
  3. modified the milestones: v4.3, v4.4 on Mar 21, 2023
  4. jorenvandeweyer commented on Aug 26, 2023

    @jorenvandeweyer
    MemberAuthor

    fixed in #229 & #228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions