From 7ea48e24f1ddac304c6fdd9b0cc3d2139fe379ff Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 10 Aug 2023 14:56:14 +0100 Subject: [PATCH] Fix secrets, NHost Signature and router issues --- app/controllers/api/migrations.php | 14 +++++++------- app/controllers/general.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 8d961a0450..a06adb98f6 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -146,12 +146,12 @@ App::post('/v1/migrations/firebase/oauth') $dbForConsole->updateDocument('identities', $identity->getId(), $identity); } - if ($identity->getAttribute('secret')) { - $serviceAccount = $identity->getAttribute('secret'); + if ($identity->getAttribute('secrets')) { + $serviceAccount = $identity->getAttribute('secrets'); } else { $serviceAccount = $firebase->createServiceAccount($accessToken, $projectId); $identity = $identity - ->setAttribute('secret', $serviceAccount); + ->setAttribute('secrets', $serviceAccount); $dbForConsole->updateDocument('identities', $identity->getId(), $identity); } @@ -309,7 +309,7 @@ App::post('/v1/migrations/nhost') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_MIGRATION) ->param('resources', [], new ArrayList(new WhiteList(NHost::getSupportedResources())), 'List of resources to migrate') - ->param('subdomain', '', new URL(), 'Source\'s Subdomain') + ->param('subdomain', '', new Text(512), 'Source\'s Subdomain') ->param('region', '', new Text(512), 'Source\'s Region') ->param('adminSecret', '', new Text(512), 'Source\'s Admin Secret') ->param('database', '', new Text(512), 'Source\'s Database Name') @@ -542,12 +542,12 @@ App::get('/v1/migrations/firebase/report/oauth') } // Get Service Account - if ($identity->getAttribute('secret')) { - $serviceAccount = $identity->getAttribute('secret'); + if ($identity->getAttribute('secrets')) { + $serviceAccount = $identity->getAttribute('secrets'); } else { $serviceAccount = $firebase->createServiceAccount($accessToken, $projectId); $identity = $identity - ->setAttribute('secret', $serviceAccount); + ->setAttribute('secrets', $serviceAccount); $dbForConsole->updateDocument('identities', $identity->getId(), $identity); } diff --git a/app/controllers/general.php b/app/controllers/general.php index d8cc537b20..53e7f73e47 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -191,7 +191,7 @@ App::init() $host = $request->getHostname() ?? ''; $mainDomain = App::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain - if ($host !== $mainDomain && $host !== 'localhost') { + if ($host !== $mainDomain && $host !== 'localhost' && $host !== 'appwrite') { if (router($utopia, $dbForConsole, $swooleRequest, $request, $response)) { return; } @@ -489,7 +489,7 @@ App::options() $host = $request->getHostname() ?? ''; $mainDomain = App::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain - if ($host !== $mainDomain && $host !== 'localhost') { + if ($host !== $mainDomain && $host !== 'localhost' && $host !== 'appwrite') { if (router($utopia, $dbForConsole, $swooleRequest, $request, $response)) { return; }