From 970b1b8192e3bdab6e0dc8c18dc69bee5453e2f1 Mon Sep 17 00:00:00 2001 From: Alexander Zaslonov Date: Mon, 22 Jun 2020 12:08:17 -0700 Subject: [PATCH] Added scope override to OAuth flows. (#716) --- .../operation-details/ko/runtime/operation-console.ts | 7 +++++++ src/models/authorizationServer.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/operations/operation-details/ko/runtime/operation-console.ts b/src/components/operations/operation-details/ko/runtime/operation-console.ts index 7451130b0..ced8fb37f 100644 --- a/src/components/operations/operation-details/ko/runtime/operation-console.ts +++ b/src/components/operations/operation-details/ko/runtime/operation-console.ts @@ -515,7 +515,14 @@ export class OperationConsole { return; } + const api = this.api(); const authorizationServer = this.authorizationServer(); + const scopeOverride = api.authenticationSettings?.oAuth2?.scope; + + if (scopeOverride) { + authorizationServer.scopes = [scopeOverride]; + } + const accessToken = await this.oauthService.authenticate(grantType, authorizationServer); this.setAuthorizationHeader(accessToken); diff --git a/src/models/authorizationServer.ts b/src/models/authorizationServer.ts index 8286b28f7..25db60398 100644 --- a/src/models/authorizationServer.ts +++ b/src/models/authorizationServer.ts @@ -8,7 +8,7 @@ export class AuthorizationServer { public readonly authorizationEndpoint: string; public readonly tokenEndpoint: string; public readonly grantTypes: string[]; - public readonly scopes: string[]; + public scopes: string[]; constructor(contract: AuthorizationServerContract) {