From 621e49e4b6890b32781e2638d35cdfe9681b132c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 20 Aug 2023 13:43:06 +0200 Subject: [PATCH 1/2] Add host to execution detail --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index 8edaae81fd..3d0e652b6b 100644 --- a/app/init.php +++ b/app/init.php @@ -186,7 +186,7 @@ const APP_AUTH_TYPE_ADMIN = 'Admin'; // Response related const MAX_OUTPUT_CHUNK_SIZE = 2 * 1024 * 1024; // 2MB // Function headers -const FUNCTION_ALLOWLIST_HEADERS_REQUEST = ['content-type', 'agent', 'content-length']; +const FUNCTION_ALLOWLIST_HEADERS_REQUEST = ['content-type', 'agent', 'content-length', 'host']; const FUNCTION_ALLOWLIST_HEADERS_RESPONSE = ['content-type', 'content-length']; // Usage metrics const METRIC_TEAMS = 'teams'; From 7bdbd512559e02820f5d1c9e2dde91d74ef27c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 20 Aug 2023 14:14:05 +0200 Subject: [PATCH 2/2] PR review changes --- app/config/errors.php | 5 +++++ app/config/roles.php | 11 +++++------ app/controllers/general.php | 2 +- src/Appwrite/Extend/Exception.php | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 3638c616ce..00b177480d 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -631,6 +631,11 @@ return [ 'description' => 'Host is not trusted. Add a custom domain to your project first.', 'code' => 404, ], + Exception::ROUTER_DOMAIN_NOT_CONFIGURED => [ + 'name' => Exception::ROUTER_DOMAIN_NOT_CONFIGURED, + 'description' => 'Please configure domain environment variables before using Appwrite outside of localhost.', + 'code' => 500, + ], Exception::RULE_RESOURCE_NOT_FOUND => [ 'name' => Exception::RULE_RESOURCE_NOT_FOUND, 'description' => 'Resource could not be found. Check resourceId and resourceType.', diff --git a/app/config/roles.php b/app/config/roles.php index 256766d3a4..ec9cf51bf1 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -61,7 +61,6 @@ return [ Auth::USER_ROLE_GUESTS => [ 'label' => 'Guests', 'scopes' => [ - 'none', 'public', 'home', 'console', @@ -77,22 +76,22 @@ return [ ], Auth::USER_ROLE_USERS => [ 'label' => 'Users', - 'scopes' => \array_merge($member, [ 'none' ]), + 'scopes' => \array_merge($member), ], Auth::USER_ROLE_ADMIN => [ 'label' => 'Admin', - 'scopes' => \array_merge($admins, [ 'none' ]), + 'scopes' => \array_merge($admins), ], Auth::USER_ROLE_DEVELOPER => [ 'label' => 'Developer', - 'scopes' => \array_merge($admins, [ 'none' ]), + 'scopes' => \array_merge($admins), ], Auth::USER_ROLE_OWNER => [ 'label' => 'Owner', - 'scopes' => \array_merge($member, $admins, [ 'none' ]), + 'scopes' => \array_merge($member, $admins), ], Auth::USER_ROLE_APPS => [ 'label' => 'Applications', - 'scopes' => ['health.read', 'graphql', 'none'], + 'scopes' => ['health.read', 'graphql'], ], ]; diff --git a/app/controllers/general.php b/app/controllers/general.php index 530f76584b..e8ab7f1320 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -60,7 +60,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques $mainDomain = App::getEnv('_APP_DOMAIN', ''); if ($mainDomain === 'localhost') { - throw new AppwriteException(AppwriteException::GENERAL_SERVER_ERROR, 'Please configure domain environment variables before using Appwrite outside of localhost.'); + throw new AppwriteException(AppwriteException::ROUTER_DOMAIN_NOT_CONFIGURED); } else { throw new AppwriteException(AppwriteException::ROUTER_HOST_NOT_FOUND); } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index aca8fd6a44..0d1b285d86 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -195,6 +195,7 @@ class Exception extends \Exception /** Router */ public const ROUTER_HOST_NOT_FOUND = 'router_host_not_found'; + public const ROUTER_DOMAIN_NOT_CONFIGURED = 'router_domain_not_configured'; /** Proxy */ public const RULE_RESOURCE_NOT_FOUND = 'rule_resource_not_found';