From 2c3c6739c5b4794485e750c953fd67353d683ec3 Mon Sep 17 00:00:00 2001 From: Antonin Bouchal Date: Tue, 26 May 2020 12:44:23 +0200 Subject: [PATCH] Passing validated scope into generateAccessToken. --- lib/grant-types/authorization-code-grant-type.ts | 4 ++-- lib/grant-types/client-credentials-grant-type.ts | 2 +- lib/grant-types/implicit-grant-type.ts | 6 +++--- lib/grant-types/password-grant-type.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/grant-types/authorization-code-grant-type.ts b/lib/grant-types/authorization-code-grant-type.ts index f00c82c71..ba9c9cae8 100755 --- a/lib/grant-types/authorization-code-grant-type.ts +++ b/lib/grant-types/authorization-code-grant-type.ts @@ -183,8 +183,8 @@ export class AuthorizationCodeGrantType extends AbstractGrantType { scope: string, ) { const accessScope = await this.validateScope(user, client, scope); - const accessToken = await this.generateAccessToken(client, user, scope); - const refreshToken = await this.generateRefreshToken(client, user, scope); + const accessToken = await this.generateAccessToken(client, user, accessScope); + const refreshToken = await this.generateRefreshToken(client, user, accessScope); const accessTokenExpiresAt = this.getAccessTokenExpiresAt(); const refreshTokenExpiresAt = this.getRefreshTokenExpiresAt(); diff --git a/lib/grant-types/client-credentials-grant-type.ts b/lib/grant-types/client-credentials-grant-type.ts index 80736bbac..451aa97f9 100755 --- a/lib/grant-types/client-credentials-grant-type.ts +++ b/lib/grant-types/client-credentials-grant-type.ts @@ -65,7 +65,7 @@ export class ClientCredentialsGrantType extends AbstractGrantType { async saveToken(user: User, client: Client, scope: string) { const accessScope = await this.validateScope(user, client, scope); - const accessToken = await this.generateAccessToken(client, user, scope); + const accessToken = await this.generateAccessToken(client, user, accessScope); const accessTokenExpiresAt = this.getAccessTokenExpiresAt(); const token = { diff --git a/lib/grant-types/implicit-grant-type.ts b/lib/grant-types/implicit-grant-type.ts index a37670482..176a55a26 100644 --- a/lib/grant-types/implicit-grant-type.ts +++ b/lib/grant-types/implicit-grant-type.ts @@ -48,14 +48,14 @@ export class ImplicitGrantType extends AbstractGrantType { */ async saveToken(user: User, client: Client, scope: string) { - const validatedScope = await this.validateScope(user, client, scope); - const accessToken = await this.generateAccessToken(client, user, scope); + const accessScope = await this.validateScope(user, client, scope); + const accessToken = await this.generateAccessToken(client, user, accessScope); const accessTokenExpiresAt = this.getAccessTokenExpiresAt(); const token = { accessToken, accessTokenExpiresAt, - scope: validatedScope, + scope: accessScope, } as Token; return this.model.saveToken(token, client, user); diff --git a/lib/grant-types/password-grant-type.ts b/lib/grant-types/password-grant-type.ts index ca07b06ed..5f8c62b8d 100755 --- a/lib/grant-types/password-grant-type.ts +++ b/lib/grant-types/password-grant-type.ts @@ -90,8 +90,8 @@ export class PasswordGrantType extends AbstractGrantType { async saveToken(user: User, client: Client, scope: string) { const accessScope = await this.validateScope(user, client, scope); - const accessToken = await this.generateAccessToken(client, user, scope); - const refreshToken = await this.generateRefreshToken(client, user, scope); + const accessToken = await this.generateAccessToken(client, user, accessScope); + const refreshToken = await this.generateRefreshToken(client, user, accessScope); const accessTokenExpiresAt = this.getAccessTokenExpiresAt(); const refreshTokenExpiresAt = this.getRefreshTokenExpiresAt();