diff --git a/.env b/.env index 3f66c898fa..43c198a683 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -_APP_ENV=production +_APP_ENV=development _APP_LOCALE=en _APP_WORKER_PER_CORE=10 _APP_CONSOLE_WHITELIST_ROOT=disabled @@ -13,10 +13,10 @@ _APP_SYSTEM_RESPONSE_FORMAT= _APP_OPTIONS_ABUSE=disabled _APP_OPTIONS_FORCE_HTTPS=disabled _APP_OPENSSL_KEY_V1=your-secret-key -_APP_DOMAIN=g4main.matejbaco.eu -_APP_DOMAIN_FUNCTIONS=functions.g4main.matejbaco.eu +_APP_DOMAIN=localhost +_APP_DOMAIN_FUNCTIONS=functions.localhost _APP_DOMAIN_DO_TOKEN= -_APP_DOMAIN_TARGET=g4main.matejbaco.eu +_APP_DOMAIN_TARGET=localhost _APP_REDIS_HOST=redis _APP_REDIS_PORT=6379 _APP_REDIS_PASS= diff --git a/app/config/errors.php b/app/config/errors.php index a501ebafb9..febe2ff956 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -531,8 +531,8 @@ return [ ], Exception::RULE_CONFIGURATION_MISSING => [ 'name' => Exception::RULE_CONFIGURATION_MISSING, - 'description' => 'Configuration for _APP_DOMAIN_TARGET missing proper domain.', - 'code' => 500, + 'description' => '_APP_DOMAIN_TARGET must be a public domain.', + 'code' => 501, ], Exception::RULE_RESOURCE_ID_NOT_FOUND => [ 'name' => Exception::RULE_RESOURCE_ID_NOT_FOUND, diff --git a/app/console b/app/console index 884a5ba74c..5cebe875f1 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 884a5ba74cc0b7755bcb21caedf5b1a68acdca05 +Subproject commit 5cebe875f1987487bce16a7a1af0a981dbd9bad9 diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d6193694f2..5d893a1e21 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -129,6 +129,7 @@ App::post('/v1/functions') ])) ); + // TODO: @Meldiron this doesnt seem to work. Same for certificate.php worker. When working, implement with Console (instead of interval) /** Trigger Webhook */ $ruleModel = new Rule(); $ruleCreate = new Event(Event::WEBHOOK_QUEUE_NAME, Event::WEBHOOK_CLASS_NAME); diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 1f6d7c189e..afea34858a 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -65,12 +65,6 @@ App::post('/v1/proxy/rules') throw new Exception(Exception::RULE_ALREADY_EXISTS, $message); } - $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); - - if (!$target->isKnown() || $target->isTest()) { - throw new Exception(Exception::RULE_CONFIGURATION_MISSING); - } - $resourceInternalId = ''; if($resourceType == 'function') { @@ -258,7 +252,7 @@ App::patch('/v1/proxy/rules/:ruleId/verification') $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); if (!$target->isKnown() || $target->isTest()) { - throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.'); + throw new Exception(Exception::RULE_CONFIGURATION_MISSING); } if ($rule->getAttribute('verification') === true) { diff --git a/app/controllers/general.php b/app/controllers/general.php index 1a5f8769df..b9a778972d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -55,11 +55,6 @@ function router(Database $dbForConsole, string $host, SwooleRequest $swooleReque throw new AppwriteException(AppwriteException::ROUTER_UNKNOWN_HOST); } - // Un-verified ignores Appwrite Router. Behaves as Appwrite API. Needed for certificate generation (well-known route) - if($route->getAttribute('status') !== 'verified') { - return false; - } - $projectId = $route->getAttribute('projectId'); $project = Authorization::skip( fn() => $dbForConsole->getDocument('projects', $projectId) @@ -665,6 +660,7 @@ App::get('/humans.txt') $response->text($template->render(false)); }); +// TODO: @Meldiron this must run before Appwrite Router. Router makes it NOT get here. But it needs to. This must be endpoint reserved by Appwrite for certificate generation and re-generation App::get('/.well-known/acme-challenge') ->desc('SSL Verification') ->label('scope', 'public') diff --git a/app/workers/certificates.php b/app/workers/certificates.php index cab59f3b46..6513e6c89a 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -413,7 +413,7 @@ class CertificatesV1 extends Worker if(!$rule->isEmpty()) { $rule->setAttribute('certificateId', $certificateId); - $rule->setAttribute('status', $success ? 'verified' : 'failed'); + $rule->setAttribute('status', $success ? 'verified' : 'unverified'); $this->dbForConsole->updateDocument('rules', $rule->getId(), $rule); $projectId = $rule->getAttribute('projectId'); diff --git a/src/Appwrite/Utopia/Response/Model/Rule.php b/src/Appwrite/Utopia/Response/Model/Rule.php index dd8221045d..5d8a038546 100644 --- a/src/Appwrite/Utopia/Response/Model/Rule.php +++ b/src/Appwrite/Utopia/Response/Model/Rule.php @@ -50,7 +50,7 @@ class Rule extends Model ]) ->addRule('status', [ 'type' => self::TYPE_STRING, - 'description' => 'Domain verification status. Possible values are "created", "verifying", "verified" and "failed"', + 'description' => 'Domain verification status. Possible values are "created", "verifying", "verified" and "unverified"', 'default' => false, 'example' => 'verified', ])