1
0
Fork 0
mirror of synced 2024-07-12 09:56:08 +12:00

deny API request to paused projects

This commit is contained in:
Damodar Lohani 2023-03-21 06:11:37 +00:00
parent 3bd92187f4
commit b2a51f3ff9
3 changed files with 11 additions and 0 deletions

View file

@ -28,6 +28,11 @@ return [
'description' => 'The request originated from an unknown origin. If you trust this domain, please list it as a trusted platform in the Appwrite console.',
'code' => 403,
],
Exception::GENERAL_PROJECT_PAUSED => [
'name' => Exception::GENERAL_PROJECT_PAUSED,
'description' => 'The requested project is paused. You can resume the project from the Appwrite console.',
'code' => 503,
],
Exception::GENERAL_SERVICE_DISABLED => [
'name' => Exception::GENERAL_SERVICE_DISABLED,
'description' => 'The requested service is disabled. You can enable the service from the Appwrite console.',

View file

@ -346,6 +346,11 @@ App::init()
Authorization::setRole($authRole);
}
$paused = $project->getAttribute('paused', false);
if ($paused && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles()))) {
throw new AppwriteException(AppwriteException::GENERAL_PROJECT_PAUSED);
}
$service = $route->getLabel('sdk.namespace', '');
if (!empty($service)) {
if (

View file

@ -39,6 +39,7 @@ class Exception extends \Exception
public const GENERAL_MOCK = 'general_mock';
public const GENERAL_ACCESS_FORBIDDEN = 'general_access_forbidden';
public const GENERAL_UNKNOWN_ORIGIN = 'general_unknown_origin';
public const GENERAL_PROJECT_PAUSED = 'general_project_paused';
public const GENERAL_SERVICE_DISABLED = 'general_service_disabled';
public const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
public const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';