我做了一些搜索,但没有找到与我的问题相关的任何内容。
我目前正在尝试对我的网站实施 Facebook 登录,但由于 htaccess mod 重写 URL,我在登录身份验证方面遇到了问题?
该代码工作完美,如果我在没有 mod 重写规则的情况下使用它,我会登录,例如:
domain.com/view_webhosting.php?webhosting=name
但是当我转到 mod 重写 URL 时
domain.com/webhosting-name/
然后它就不起作用并抛出错误“CSRF 状态令牌与提供的令牌不匹配”。
在 htaccess 文件中,它看起来像这样
RewriteRule ^webhosting-([a-z_0-9-]+)/$ /view_webhosting.php?webhosting=$1 [L]
有人有解决这样的问题的方法吗?我正在使用 Facebook SDK v3.1.1
PHP SDK 期望重定向后的“state”字段位于 $_REQUEST 中(我认为是 GET 参数),然后才能将“代码”交换为访问令牌。来自base_facebook.php:
protected function getCode() {
if (isset($_REQUEST['code'])) {
if ($this->state !== null &&
isset($_REQUEST['state']) &&
$this->state === $_REQUEST['state']) {
// CSRF state has done its job, so clear it
$this->state = null;
$this->clearPersistentData('state');
return $_REQUEST['code'];
} else {
self::errorLog('CSRF state token does not match one provided.');
return false;
}
}
return false;
}
您的 RewriteRule 可能会破坏该参数。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)