Merge pull request #9027 from appwrite/fix-no-pool-access

Fix no pool access
This commit is contained in:
Shimon Newman 2024-11-26 11:08:45 +02:00 committed by GitHub
commit 9ca420a0e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View file

@ -133,7 +133,7 @@ App::post('/v1/projects')
$databaseKeys = System::getEnv('_APP_DATABASE_KEYS', '');
$keys = explode(',', $databaseKeys);
$databases = array_filter($keys, function ($value) use ($region) {
return str_contains($value, $region);
return str_contains($value, $region);
});
}

View file

@ -264,9 +264,15 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
$region = System::getEnv('_APP_REGION', 'fra');
$cache = $app->getResource('cache');
foreach ($sharedTablesV2 as $hostname) {
$regionDatabases = \array_filter(
$sharedTablesV2,
fn ($hostname) => \str_contains($hostname, $region)
);
foreach ($regionDatabases as $hostname) {
$adapter = $pools
->get($hostname)
->pop()

View file

@ -1334,7 +1334,7 @@ App::setResource('project', function ($dbForConsole, $request, $console) {
$project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId));
if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){
if ($project->getAttribute('region') !== System::getEnv('_APP_REGION')) {
throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint');
}