0

Set authorization module uLogin for Codeigniter http://ulogin.ru/constructor.html

However, it causes an error ("The action you have requested is not allowed.") if enabled CSRF protection.

If the protection is turned off, everything works fine.

If protection is enabled, then after logging and automatic refresh the current page fails.

Apparently due discrepancies passed token. How to solve this problem?

4

2 回答 2

1

CodeIgniter CSRF 有一个设置可能会导致您的问题。在 /config/config.php 中,该设置$config['csrf_expire']决定了 CSRF cookie 的有效期。例如,如果该设置为 300(5 分钟),并且您刷新了登录页面但在 10 分钟内没有尝试登录,您将收到错误"The action you have requested is not allowed."消息,因为 CSRF cookie 在 5 分钟前过期。

本质上,该错误可能来自 CodeIgniter CSRF cookie 已过期。该 cookie 是在页面加载时设置的,因此如果带有表单的页面在此处停留的时间超过$config['csrf_expire']设置时间,则您必须在提交表单之前刷新页面,否则您将收到该错误。为避免经常出现错误,请尝试增加$config['csrf_expire'].

此外,如果您使用 CodeIgniter表单助手,隐藏的 CSRF 输入将自动生成。

于 2012-12-20T16:13:34.390 回答
0

我不熟悉链接的“模块”,但您需要在登录表单中添加一个隐藏字段,其中包含 CSRF 验证数据,如下所示:

<input type="hidden"
    name="<?=$this->security->get_csrf_token_name();?>"
    value="<?=$this->security->get_csrf_hash();?>"
/>
于 2012-12-18T09:39:51.070 回答