deny API request to paused projects
This commit is contained in:
parent
3bd92187f4
commit
b2a51f3ff9
3 changed files with 11 additions and 0 deletions
|
@ -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.',
|
'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,
|
'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 => [
|
Exception::GENERAL_SERVICE_DISABLED => [
|
||||||
'name' => Exception::GENERAL_SERVICE_DISABLED,
|
'name' => Exception::GENERAL_SERVICE_DISABLED,
|
||||||
'description' => 'The requested service is disabled. You can enable the service from the Appwrite console.',
|
'description' => 'The requested service is disabled. You can enable the service from the Appwrite console.',
|
||||||
|
|
|
@ -346,6 +346,11 @@ App::init()
|
||||||
Authorization::setRole($authRole);
|
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', '');
|
$service = $route->getLabel('sdk.namespace', '');
|
||||||
if (!empty($service)) {
|
if (!empty($service)) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Exception extends \Exception
|
||||||
public const GENERAL_MOCK = 'general_mock';
|
public const GENERAL_MOCK = 'general_mock';
|
||||||
public const GENERAL_ACCESS_FORBIDDEN = 'general_access_forbidden';
|
public const GENERAL_ACCESS_FORBIDDEN = 'general_access_forbidden';
|
||||||
public const GENERAL_UNKNOWN_ORIGIN = 'general_unknown_origin';
|
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_SERVICE_DISABLED = 'general_service_disabled';
|
||||||
public const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
|
public const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
|
||||||
public const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
|
public const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
|
||||||
|
|
Loading…
Reference in a new issue