From ff5186a6a0543ffc6680bebdcc9cfffad9bf4cd3 Mon Sep 17 00:00:00 2001 From: eldadfux Date: Tue, 3 Sep 2019 10:43:06 +0300 Subject: [PATCH] Updated OAuth endpoints --- app/config/services.php | 7 +------ app/controllers/auth.php | 6 +++--- app/views/console/users/index.phtml | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/config/services.php b/app/config/services.php index 113dc5343c..409fbdc8ea 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -17,17 +17,12 @@ return [ 'controller' => 'controllers/account.php', 'sdk' => true, ], - 'v1/auth' => [ //TODO MOVE TO AUTH CONTROLLER SCOPE -- You can also learn how to [configure support for our supported OAuth providers](/docs/oauth) + 'v1/auth' => [ // Add to docs later: You can also learn how to [configure support for our supported OAuth providers](/docs/oauth) 'name' => 'Auth', 'description' => "The authentication service allows you to verify users accounts using basic email and password login or with a supported OAuth provider. The auth service also exposes methods to confirm users email account and recover users forgotten passwords.\n\n. You can review our currently available OAuth providers from your project console under the **'users'** menu.", 'controller' => 'controllers/auth.php', 'sdk' => true, ], - 'v1/oauth' => [ - 'name' => 'OAuth', - 'controller' => 'controllers/auth.php', - 'sdk' => true, - ], 'v1/avatars' => [ 'name' => 'Avatars', 'description' => 'The avatars service aims to help you complete common and recitative tasks related to your app images, icons and avatars. Using this service we hope to save you some precious time and help you focus on solving your app real challenges.', diff --git a/app/controllers/auth.php b/app/controllers/auth.php index 138876f5d8..0d032e2db5 100644 --- a/app/controllers/auth.php +++ b/app/controllers/auth.php @@ -608,7 +608,7 @@ $utopia->get('/v1/auth/oauth/:provider') ->action( function($provider, $success, $failure) use ($response, $request, $project) { - $callback = $request->getServer('REQUEST_SCHEME', 'https') . '://' . $request->getServer('HTTP_HOST') . '/v1/oauth/callback/' . $provider . '/' . $project->getUid(); + $callback = $request->getServer('REQUEST_SCHEME', 'https') . '://' . $request->getServer('HTTP_HOST') . '/v1/auth/oauth/callback/' . $provider . '/' . $project->getUid(); $appId = $project->getAttribute('usersOauth' . ucfirst($provider) . 'Appid', ''); $appSecret = $project->getAttribute('usersOauth' . ucfirst($provider) . 'Secret', '{}'); @@ -674,7 +674,7 @@ $utopia->get('/v1/auth/oauth/callback/:provider/:projectId') ->action( function($projectId, $provider, $code, $state) use ($response, $request, $domain) { - $response->redirect($request->getServer('REQUEST_SCHEME', 'https') . '://' . $domain . '/v1/oauth/' . $provider . '/redirect?' + $response->redirect($request->getServer('REQUEST_SCHEME', 'https') . '://' . $domain . '/v1/auth/oauth/' . $provider . '/redirect?' . http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); } ); @@ -695,7 +695,7 @@ $utopia->get('/v1/auth/oauth/:provider/redirect') ->action( function($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit) { - $callback = $request->getServer('REQUEST_SCHEME', 'https') . '://' . $request->getServer('HTTP_HOST') . '/v1/oauth/callback/' . $provider . '/' . $project->getUid(); + $callback = $request->getServer('REQUEST_SCHEME', 'https') . '://' . $request->getServer('HTTP_HOST') . '/v1/auth/oauth/callback/' . $provider . '/' . $project->getUid(); $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; $validateURL = new URL(); diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index 89564a04b2..a3b2a6017d 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -344,7 +344,7 @@ $providers = $this->getParam('providers', []);

To complete set up, add this OAuth redirect URI to your app configuration.

- +