mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-23 20:32:14 +09:00
Move SSL redirection logic to Context::init()
This commit is contained in:
parent
65df40ad9f
commit
b5740052fc
15 changed files with 199 additions and 126 deletions
|
|
@ -49,6 +49,32 @@ class moduleController extends module
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add action security
|
||||
*/
|
||||
function insertActionSecurity($act)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->act = $act;
|
||||
$output = executeQuery('module.insertActionSecurity', $args);
|
||||
|
||||
Rhymix\Framework\Cache::delete('action_security');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete action security
|
||||
*/
|
||||
function deleteActionSecurity($act)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->act = $act;
|
||||
$output = executeQuery('module.deleteActionSecurity', $args);
|
||||
|
||||
Rhymix\Framework\Cache::delete('action_security');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add trigger callback function
|
||||
*
|
||||
|
|
@ -1362,6 +1388,28 @@ class moduleController extends module
|
|||
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all secure actions are registered. If not, register them.
|
||||
*
|
||||
* @param string $module_name
|
||||
* @return object
|
||||
*/
|
||||
public function registerSecureActions(string $module_name)
|
||||
{
|
||||
$action_security = ModuleModel::getActionSecurity();
|
||||
$module_action_info = ModuleModel::getModuleActionXml($module_name);
|
||||
|
||||
foreach ($module_action_info->action ?: [] as $action_name => $action_info)
|
||||
{
|
||||
if ($action_info->use_ssl === 'true' && !isset($action_security[$action_name]))
|
||||
{
|
||||
$output = $this->insertActionSecurity($action_name);
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseObject();
|
||||
}
|
||||
}
|
||||
/* End of file module.controller.php */
|
||||
/* Location: ./modules/module/module.controller.php */
|
||||
|
|
|
|||
|
|
@ -602,6 +602,38 @@ class moduleModel extends module
|
|||
return $action_forward[$act];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get SSL action setting
|
||||
*/
|
||||
public static function getActionSecurity($act = null)
|
||||
{
|
||||
$action_security = Rhymix\Framework\Cache::get('action_security');
|
||||
if($action_security === null)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$output = executeQueryArray('module.getActionSecurity', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$action_security = array();
|
||||
foreach($output->data as $item)
|
||||
{
|
||||
$action_security[$item->act] = true;
|
||||
}
|
||||
|
||||
Rhymix\Framework\Cache::set('action_security', $action_security, 0, true);
|
||||
}
|
||||
|
||||
if(!isset($act))
|
||||
{
|
||||
return $action_security;
|
||||
}
|
||||
|
||||
return isset($action_security[$act]) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get trigger functions
|
||||
*/
|
||||
|
|
@ -1347,6 +1379,9 @@ class moduleModel extends module
|
|||
|
||||
// Get action forward
|
||||
$action_forward = self::getActionForward();
|
||||
|
||||
// Get action security
|
||||
$action_security = self::getActionSecurity();
|
||||
|
||||
foreach ($searched_list as $module_name)
|
||||
{
|
||||
|
|
@ -1431,6 +1466,15 @@ class moduleModel extends module
|
|||
$info->need_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if all secure actions are registered
|
||||
foreach ($module_action_info->action ?: [] as $action_name => $action_info)
|
||||
{
|
||||
if ($action_info->use_ssl === 'true' && !isset($action_security[$action_name]))
|
||||
{
|
||||
$info->need_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list[] = $info;
|
||||
}
|
||||
|
|
|
|||
8
modules/module/queries/deleteActionSecurity.xml
Normal file
8
modules/module/queries/deleteActionSecurity.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="deleteActionSecurity" action="delete">
|
||||
<tables>
|
||||
<table name="action_security" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="act" var="act" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
11
modules/module/queries/getActionSecurity.xml
Normal file
11
modules/module/queries/getActionSecurity.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="getActionSecurity" action="select">
|
||||
<tables>
|
||||
<table name="action_security" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="act" var="act" />
|
||||
</conditions>
|
||||
</query>
|
||||
8
modules/module/queries/insertActionSecurity.xml
Normal file
8
modules/module/queries/insertActionSecurity.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="insertActionSecurity" action="insert">
|
||||
<tables>
|
||||
<table name="action_security" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="act" var="act" notnull="notnull" />
|
||||
</columns>
|
||||
</query>
|
||||
3
modules/module/schemas/action_security.xml
Normal file
3
modules/module/schemas/action_security.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<table name="action_security">
|
||||
<column name="act" type="varchar" size="80" notnull="notnull" primary_key="primary_key" />
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue