diff --git a/.env b/.env index 8ff8164a21..2470c786b1 100644 --- a/.env +++ b/.env @@ -23,6 +23,7 @@ _APP_OPENSSL_KEY_V1=your-secret-key _APP_DOMAIN=traefik _APP_DOMAIN_FUNCTIONS=functions.localhost _APP_DOMAIN_TARGET=localhost +_APP_RULES_FORMAT=md5 _APP_REDIS_HOST=redis _APP_REDIS_PORT=6379 _APP_REDIS_PASS= diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 5dc67677ac..e38dba3f19 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -329,7 +329,7 @@ App::post('/v1/functions') $routeSubdomain = ID::unique(); $domain = "{$routeSubdomain}.{$functionsDomain}"; // TODO: @christyjacob remove once we migrate the rules in 1.7.x - $ruleId = version_compare(APP_VERSION_STABLE, '1.7.0', '<') ? ID::unique() : md5($domain); + $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); $rule = Authorization::skip( fn () => $dbForConsole->createDocument('rules', new Document([ diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 029bc5e8b3..8ff921ffeb 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -61,13 +61,12 @@ App::post('/v1/proxy/rules') } // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { + $document = $dbForConsole->getDocument('rules', md5($domain)); + } else { $document = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]), ]); - } else { - $ruleId = md5($domain); - $document = $dbForConsole->getDocument('rules', $ruleId); } @@ -111,7 +110,7 @@ App::post('/v1/proxy/rules') } // TODO: @christyjacob remove once we migrate the rules in 1.7.x - $ruleId = version_compare(APP_VERSION_STABLE, '1.7.0', '<') ? ID::unique() : md5($domain->get()); + $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(); $rule = new Document([ '$id' => $ruleId, diff --git a/app/controllers/general.php b/app/controllers/general.php index 4f38369237..54e6e1e791 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -56,15 +56,15 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo } // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { + $route = Authorization::skip(fn () => $dbForConsole->getDocument('rules', md5($host))); + } else { $route = Authorization::skip( fn () => $dbForConsole->find('rules', [ Query::equal('domain', [$host]), Query::limit(1) ]) )[0] ?? new Document(); - } else { - $route = Authorization::skip(fn () => $dbForConsole->getDocument('rules', md5($host))); } if ($route->isEmpty()) { @@ -528,10 +528,10 @@ App::init() $mainDomain = $envDomain; } else { // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { - $domainDocument = $dbForConsole->findOne('rules', [Query::orderAsc('$id')]); - } else { + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { $domainDocument = $dbForConsole->getDocument('rules', md5($envDomain)); + } else { + $domainDocument = $dbForConsole->findOne('rules', [Query::orderAsc('$id')]); } $mainDomain = !$domainDocument->isEmpty() ? $domainDocument->getAttribute('domain') : $domain->get(); } @@ -540,18 +540,18 @@ App::init() Console::warning($domain->get() . ' is not a main domain. Skipping SSL certificate generation.'); } else { // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { + $domainDocument = $dbForConsole->getDocument('rules', md5($domain->get())); + } else { $domainDocument = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain->get()]) ]); - } else { - $domainDocument = $dbForConsole->getDocument('rules', md5($domain->get())); } if ($domainDocument->isEmpty()) { $domainDocument = new Document([ // TODO: @christyjacob remove once we migrate the rules in 1.7.x - '$id' => version_compare(APP_VERSION_STABLE, '1.7.0', '<') ? ID::unique() : md5($domain->get()), + '$id' => System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(), 'domain' => $domain->get(), 'resourceType' => 'api', 'status' => 'verifying', diff --git a/composer.lock b/composer.lock index bdb41c2478..317ae6d33e 100644 --- a/composer.lock +++ b/composer.lock @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.28.3", + "version": "v4.29.0", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100" + "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/c5c311e0f3d89928251ac5a2f0e3db283612c100", - "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/0ef6b2eb74b782f3f9023276c324d22e440f7587", + "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.28.3" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.0" }, - "time": "2024-10-22T22:27:17+00:00" + "time": "2024-11-27T18:37:40+00:00" }, { "name": "jean85/pretty-package-versions", @@ -2386,16 +2386,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -2433,7 +2433,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -2449,27 +2449,27 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/http-client", - "version": "v7.1.8", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a" + "reference": "2ec49720a38a8041673ba4c42512bfd845218c56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", - "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", + "url": "https://api.github.com/repos/symfony/http-client/zipball/2ec49720a38a8041673ba4c42512bfd845218c56", + "reference": "2ec49720a38a8041673ba4c42512bfd845218c56", "shasum": "" }, "require": { "php": ">=8.2", "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-client-contracts": "^3.4.1", + "symfony/http-client-contracts": "~3.4.3|^3.5.1", "symfony/service-contracts": "^2.5|^3" }, "conflict": { @@ -2527,7 +2527,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.1.8" + "source": "https://github.com/symfony/http-client/tree/v7.1.9" }, "funding": [ { @@ -2543,20 +2543,20 @@ "type": "tidelift" } ], - "time": "2024-11-13T13:40:27+00:00" + "time": "2024-11-27T11:52:45+00:00" }, { "name": "symfony/http-client-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "20414d96f391677bf80078aa55baece78b82647d" + "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/20414d96f391677bf80078aa55baece78b82647d", - "reference": "20414d96f391677bf80078aa55baece78b82647d", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/c2f3ad828596624ca39ea40f83617ef51ca8bbf9", + "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9", "shasum": "" }, "require": { @@ -2605,7 +2605,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.1" }, "funding": [ { @@ -2621,7 +2621,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-11-25T12:02:18+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2861,16 +2861,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { @@ -2924,7 +2924,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -2940,7 +2940,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "tbachert/spi", @@ -5127,16 +5127,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.2", + "version": "v1.18.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64" + "reference": "cef51821608239040ab841ad6e1c6ae502ae3026" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", - "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", + "url": "https://api.github.com/repos/laravel/pint/zipball/cef51821608239040ab841ad6e1c6ae502ae3026", + "reference": "cef51821608239040ab841ad6e1c6ae502ae3026", "shasum": "" }, "require": { @@ -5147,13 +5147,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.64.0", - "illuminate/view": "^10.48.20", - "larastan/larastan": "^2.9.8", + "friendsofphp/php-cs-fixer": "^3.65.0", + "illuminate/view": "^10.48.24", + "larastan/larastan": "^2.9.11", "laravel-zero/framework": "^10.4.0", "mockery/mockery": "^1.6.12", - "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.35.1" + "nunomaduro/termwind": "^1.17.0", + "pestphp/pest": "^2.36.0" }, "bin": [ "builds/pint" @@ -5189,7 +5189,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-11-20T09:33:46+00:00" + "time": "2024-11-26T15:34:00+00:00" }, { "name": "matthiasmullie/minify", @@ -7800,16 +7800,16 @@ }, { "name": "symfony/options-resolver", - "version": "v7.1.6", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "85e95eeede2d41cd146146e98c9c81d9214cae85" + "reference": "0f4099f5306a92487d13b2a4589068c36a93c447" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/85e95eeede2d41cd146146e98c9c81d9214cae85", - "reference": "85e95eeede2d41cd146146e98c9c81d9214cae85", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0f4099f5306a92487d13b2a4589068c36a93c447", + "reference": "0f4099f5306a92487d13b2a4589068c36a93c447", "shasum": "" }, "require": { @@ -7847,7 +7847,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.1.6" + "source": "https://github.com/symfony/options-resolver/tree/v7.1.9" }, "funding": [ { @@ -7863,7 +7863,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-11-20T11:08:58+00:00" }, { "name": "symfony/polyfill-ctype", @@ -8557,7 +8557,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index db7c73dd0c..4f32877fcf 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -340,12 +340,12 @@ class Certificates extends Action private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void { // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { + $rule = $dbForConsole->getDocument('rules', md5($domain)); + } else { $rule = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]), ]); - } else { - $rule = $dbForConsole->getDocument('rules', md5($domain)); } if (!$rule->isEmpty()) {