From 786a00d6d0fa5bb7b0e44ecef39814fe314a0cd8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 22 May 2020 12:27:27 +0200 Subject: [PATCH] plugins/auth-backend: pass on scope string as is to google provider --- plugins/auth-backend/src/providers/google/provider.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/auth-backend/src/providers/google/provider.ts b/plugins/auth-backend/src/providers/google/provider.ts index 2c559a2dc9..1e0ed83234 100644 --- a/plugins/auth-backend/src/providers/google/provider.ts +++ b/plugins/auth-backend/src/providers/google/provider.ts @@ -23,6 +23,7 @@ import { AuthProviderConfig, } from './../types'; import { postMessageResponse } from './../utils'; +import { InputError } from '@backstage/backend-common'; export class GoogleAuthProvider implements AuthProvider, AuthProviderRouteHandlers { @@ -36,9 +37,12 @@ export class GoogleAuthProvider res: express.Response, next: express.NextFunction, ) { - const scopes = req.query.scopes?.toString().split(','); + const scope = req.query.scope?.toString() ?? ''; + if (!scope) { + throw new InputError('missing scope parameter'); + } return passport.authenticate('google', { - scope: scopes, + scope, accessType: 'offline', prompt: 'consent', })(req, res, next);