HOR-1750
This commit is contained in:
@@ -254,6 +254,8 @@ class WebApplication
|
|||||||
$authenticationClass = 'ProcessMaker\\Services\\OAuth2\\Server';
|
$authenticationClass = 'ProcessMaker\\Services\\OAuth2\\Server';
|
||||||
// $accessControlClass - contains the class name that validate the Access Control for Restler
|
// $accessControlClass - contains the class name that validate the Access Control for Restler
|
||||||
$accessControlClass = 'ProcessMaker\\Policies\\AccessControl';
|
$accessControlClass = 'ProcessMaker\\Policies\\AccessControl';
|
||||||
|
// $controlUnderUpdating - ControlUnderUpdating sends an error signal 503 to report that the application is in update
|
||||||
|
$controlUnderUpdating = 'ProcessMaker\\Policies\\ControlUnderUpdating';
|
||||||
// $pmOauthClientId - contains PM Local OAuth Id (Web Designer)
|
// $pmOauthClientId - contains PM Local OAuth Id (Web Designer)
|
||||||
$pmOauthClientId = 'x-pm-local-client';
|
$pmOauthClientId = 'x-pm-local-client';
|
||||||
|
|
||||||
@@ -301,6 +303,8 @@ class WebApplication
|
|||||||
$this->rest->addAuthenticationClass($authenticationClass, '');
|
$this->rest->addAuthenticationClass($authenticationClass, '');
|
||||||
// adding $accessControlClass to Restler
|
// adding $accessControlClass to Restler
|
||||||
$this->rest->addAuthenticationClass($accessControlClass);
|
$this->rest->addAuthenticationClass($accessControlClass);
|
||||||
|
// adding $controlUnderUpdating to Restler
|
||||||
|
$this->rest->addAuthenticationClass($controlUnderUpdating);
|
||||||
|
|
||||||
// Setting database connection source
|
// Setting database connection source
|
||||||
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Policies;
|
||||||
|
|
||||||
|
use \Luracast\Restler\iAuthenticate;
|
||||||
|
use \Luracast\Restler\RestException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ControlUnderUpdating sends an error signal 503 to report that the application
|
||||||
|
* is in update.
|
||||||
|
*/
|
||||||
|
class ControlUnderUpdating implements iAuthenticate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access verification method.
|
||||||
|
*
|
||||||
|
* API access will be denied when this method returns false
|
||||||
|
*
|
||||||
|
* @return boolean true when api access is allowed false otherwise
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public function __isAllowed()
|
||||||
|
{
|
||||||
|
$response = true;
|
||||||
|
$underUpdating = \Bootstrap::isPMUnderUpdating();
|
||||||
|
if ($underUpdating['action']) {
|
||||||
|
$sysTemp = true;
|
||||||
|
if (defined("SYS_TEMP")) {
|
||||||
|
$sysTemp = $underUpdating['workspace'] == SYS_TEMP;
|
||||||
|
}
|
||||||
|
if ($underUpdating['workspace'] == "true" || $sysTemp) {
|
||||||
|
$mesage = 'The server is currently unable to handle the request '
|
||||||
|
. 'due to a temporary overloading or maintenance of the '
|
||||||
|
. 'server (An application update has probably been '
|
||||||
|
. 'performed on the server).';
|
||||||
|
throw new RestException(503, $mesage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required by interface iAuthenticate
|
||||||
|
* @return string string to be used with WWW-Authenticate header
|
||||||
|
* @example Basic
|
||||||
|
* @example Digest
|
||||||
|
* @example OAuth
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __getWWWAuthenticateString()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user