Merge remote-tracking branch 'origin/release/3.2.1' into feature/HOR-2977
This commit is contained in:
@@ -254,6 +254,8 @@ class WebApplication
|
||||
$authenticationClass = 'ProcessMaker\\Services\\OAuth2\\Server';
|
||||
// $accessControlClass - contains the class name that validate the Access Control for Restler
|
||||
$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 = 'x-pm-local-client';
|
||||
|
||||
@@ -301,6 +303,8 @@ class WebApplication
|
||||
$this->rest->addAuthenticationClass($authenticationClass, '');
|
||||
// adding $accessControlClass to Restler
|
||||
$this->rest->addAuthenticationClass($accessControlClass);
|
||||
// adding $controlUnderUpdating to Restler
|
||||
$this->rest->addAuthenticationClass($controlUnderUpdating);
|
||||
|
||||
// Setting database connection source
|
||||
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
||||
|
||||
@@ -71,7 +71,7 @@ class NotificationDeviceMapBuilder
|
||||
|
||||
$tMap->addColumn('SYS_LANG', 'SysLang', 'string', CreoleTypes::VARCHAR, false, 10);
|
||||
|
||||
$tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::VARCHAR, true, 150);
|
||||
$tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::VARCHAR, true, 255);
|
||||
|
||||
$tMap->addColumn('DEV_TYPE', 'DevType', 'string', CreoleTypes::VARCHAR, true, 50);
|
||||
|
||||
|
||||
@@ -5543,7 +5543,7 @@
|
||||
<column name="DEV_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
|
||||
<column name="USR_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
|
||||
<column name="SYS_LANG" type="VARCHAR" size="10" required="false" default=""/>
|
||||
<column name="DEV_REG_ID" type="VARCHAR" size="150" required="true" default=""/>
|
||||
<column name="DEV_REG_ID" type="VARCHAR" size="255" required="true" default=""/>
|
||||
<column name="DEV_TYPE" type="VARCHAR" size="50" required="true" default=""/>
|
||||
<column name="DEV_CREATE" type="TIMESTAMP" required="true" />
|
||||
<column name="DEV_UPDATE" type="TIMESTAMP" required="true" />
|
||||
|
||||
@@ -3077,7 +3077,7 @@ CREATE TABLE `NOTIFICATION_DEVICE`
|
||||
`DEV_UID` VARCHAR(32) default '' NOT NULL,
|
||||
`USR_UID` VARCHAR(32) default '' NOT NULL,
|
||||
`SYS_LANG` VARCHAR(10) default '',
|
||||
`DEV_REG_ID` VARCHAR(150) default '' NOT NULL,
|
||||
`DEV_REG_ID` VARCHAR(255) default '' NOT NULL,
|
||||
`DEV_TYPE` VARCHAR(50) default '' NOT NULL,
|
||||
`DEV_CREATE` DATETIME NOT NULL,
|
||||
`DEV_UPDATE` DATETIME NOT NULL,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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;
|
||||
self::verifyUnderUpgrading();
|
||||
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 '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify under upgrading, if the state is under update an exception is
|
||||
* thrown of type RestException.
|
||||
* @throws RestException
|
||||
*/
|
||||
public static function verifyUnderUpgrading()
|
||||
{
|
||||
$underUpdating = \Bootstrap::isPMUnderUpdating();
|
||||
if ($underUpdating['action']) {
|
||||
$sysTemp = true;
|
||||
if (defined('SYS_TEMP')) {
|
||||
$sysTemp = $underUpdating['workspace'] == SYS_TEMP;
|
||||
}
|
||||
if ($underUpdating['workspace'] == 'true' || $sysTemp) {
|
||||
$message = 'The server is currently unable to handle the request '
|
||||
. 'due to temporary overloading or server maintenance ('
|
||||
. 'an application update has probably been performed on '
|
||||
. 'the server)';
|
||||
throw new RestException(503, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -284,6 +284,8 @@ class Server implements iAuthenticate
|
||||
*/
|
||||
public function postToken($request = null, $returnResponse = false)
|
||||
{
|
||||
\ProcessMaker\Policies\ControlUnderUpdating::verifyUnderUpgrading();
|
||||
|
||||
// Handle a request for an OAuth2.0 Access Token and send the response to the client
|
||||
if ($request == null) {
|
||||
$request = \OAuth2\Request::createFromGlobals();
|
||||
|
||||
Reference in New Issue
Block a user