From a5bfc8668b2ecb30ced7ac17f7a52adbe681b9fe Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 12 Jan 2020 00:33:06 +0530 Subject: [PATCH] feat: added support for scope parameter in the OAuth route --- app/controllers/auth.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/auth.php b/app/controllers/auth.php index c19fa55a3e..0b48a09d95 100644 --- a/app/controllers/auth.php +++ b/app/controllers/auth.php @@ -4,6 +4,7 @@ global $utopia, $register, $request, $response, $user, $audit, $webhook, $projec use Utopia\Exception; use Utopia\Validator\WhiteList; +use Utopia\Validator\ArrayList; use Utopia\Validator\Text; use Utopia\Validator\Email; use Utopia\Validator\Host; @@ -400,8 +401,9 @@ $utopia->get('/v1/auth/login/oauth/:provider') ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth Provider. Currently, supported providers are: ' . implode(', ', array_keys($providers))) ->param('success', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.') ->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.') + ->param('scopes', [], function () { return new ArrayList(new Text(128)); }, 'An array of string where each can be max 128 chars', true) ->action( - function ($provider, $success, $failure) use ($response, $request, $project) { + function ($provider, $success, $failure, $scopes) use ($response, $request, $project) { $callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/auth/login/oauth/callback/'.$provider.'/'.$project->getUid(); $appId = $project->getAttribute('usersOauth'.ucfirst($provider).'Appid', ''); $appSecret = $project->getAttribute('usersOauth'.ucfirst($provider).'Secret', '{}');