当我启用燃料1.4的CSRF保护,我得到一个csrf令牌重置问题。
以免详细说明问题:
应用程序配置中的config.php
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 's_csrf_tocken';
$config['csrf_cookie_name'] = 's_csrf_cookie';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();在一个包含以下文件的简单模块中
名称,profile_image .
因此,当我要创建或编辑,然后上传一个文件,在配置文件图像部分,然后返回主从模块的页面。
并试图从它中保存出错误:
遇到了一个错误
您要求的操作是不允许的。
由于csrf令牌在资产的iframe中被更改,因此加载程序和主从csrf中没有得到更新。
这个问题有什么解决办法吗?
发布于 2019-10-09 11:15:07
我已经实施了一个解决方案它仍有改进的余地。我使用控制器来获取csrf。
class Csrf_secure extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->library('user_agent');
}
function get_csrf()
{
$this->fuel->admin->check_login();
if(false)
{}
elseif(trim($this->agent->referrer()) =='' or $this->input->is_ajax_request()== false)
{show_404(); }
else {
echo json_encode(array(
'token'=>$this->security->get_csrf_token_name(),
'hash'=>$this->security->get_csrf_hash()
));
} }}当模态I帧关闭时获取和更新函数
from (如果只有在from上发生更新时才能对其进行单元格化,则需要优化)
/fuel/modules/fuel/assets/js/jquery/plugins/jqModal.js
改变
$.fn.jqmHide
功能如下。
$.fn.jqmHide=function(t){return this.each(function(){
$.jqm.close(this._jqm,t);
if(typeof window.parent != "undefined" ){
if(typeof window.parent.CallParent == "undefined" ){
window.parent.CallParent = function(context)
{
$.getJSON(jqx_config.basePath+"csrf_secure/get_csrf", function(result){
if(typeof result.token != "undefined"){
document.querySelectorAll('#'+result.token).forEach(function(rf){
rf.value=result.hash;
});
}
});
};
};
window.parent.CallParent(this._jqm,t);
}
});};https://stackoverflow.com/questions/58135213
复制相似问题