Jia*_*nYA 9 php codeigniter saml saml-2.0 simplesamlphp
我正在使用SSOCircle来测试我的SAML实现与Codeigniter.目前的步骤是:
但是,在步骤3之后,它立即进入步骤4并返回步骤3.
这是我的代码:
public function index()
{
$data['languages']= get_all_languages();
$sp_auth = 'default-sp';
try {
$auth = new SimpleSAML_Auth_Simple($sp_auth);
$auth->requireAuth(array(
'ReturnTo' => $this->data['controller'],
'KeepPost' => FALSE,
));
$attributes = $auth->getAttributes();
var_dump($attributes);
} catch (Error $e) {
print_r($e);
}
}
Run Code Online (Sandbox Code Playgroud)
我认为我的重定向可能是它继续调用同意页面的原因.但是当添加另一个url以便使用此功能进行访问时
public function auth(){
$attributes = $auth->getAttributes();
var_dump($attributes);
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
SimpleSAML_Error_Error: UNHANDLEDEXCEPTION
Backtrace:
1 www/_include.php:45 (SimpleSAML_exception_handler)
0 [builtin] (N/A)
Caused by: SimpleSAML_Error_Exception: No authentication source with id 'Login/Auth' found.
Backtrace:
2 lib/SimpleSAML/Auth/Source.php:335 (SimpleSAML_Auth_Source::getById)
1 modules/saml/www/sp/saml2-acs.php:12 (require)
0 www/module.php:135 (N/A)
Run Code Online (Sandbox Code Playgroud)
我希望有人可以看看这个并帮助我.谢谢.
更新:
我最近注意到SSOCircle实际上返回到我的登录页面.但是,它会立即将其重定向回SSOCircle页面.不确定这是否有帮助
更新2:我刚检查了日志,我收到了这个警告
Mar 12 23:26:26 simplesamlphp WARNING [da20d4a7a3] Could not load state specified by InResponseTo: NOSTATE Processing response as unsolicited.
Run Code Online (Sandbox Code Playgroud)
我被告知这是因为失去了国家信息.但是我检查了我的cookie名称并且它们匹配.我还错过了什么?
https://github.com/simplesamlphp/simplesamlphp/wiki/State-Information-Lost
更新: 后续段落假设当您修改代码以避免循环重定向时,您已确保:
配置认证模块:**
在 unix 上,这可以通过运行(从 SimpleSAMLphp 安装目录)来完成:
Run Code Online (Sandbox Code Playgroud)touch modules/exampleauth/enable下一步是使用此模块创建身份验证源。认证源是具有特定配置的认证模块。每个身份验证源都有一个名称,用于引用 IdP 配置中的此特定配置。身份验证源的配置可以在 config/authsources.php 中找到。
在此设置中,该文件应包含一个条目:
Run Code Online (Sandbox Code Playgroud)<?php $config = array( 'example-userpass' => array( 'exampleauth:UserPass', 'student:studentpass' => array( 'uid' => array('student'), 'eduPersonAffiliation' => array('member', 'student'), ), 'employee:employeepass' => array( 'uid' => array('employee'), 'eduPersonAffiliation' => array('member', 'employee'), ), ), );此配置创建两个用户 - 学生和员工,密码分别为 Studentpass 和 Employeepass。用户名和密码存储在数组索引中(对于学生用户,student:studentpass。每个用户的属性在索引引用的数组中配置。对于学生用户,这些属性是:
Run Code Online (Sandbox Code Playgroud)array( 'uid' => array('student'), 'eduPersonAffiliation' => array('member', 'student'), ),当用户登录时,IdP 将返回这些属性。
应用程序的 PHP 会话设置与 SimpleSAMLphp 之间不匹配
如果您尝试添加 SAML 2.0 支持的应用程序和 SimpleSAMLphp 都使用 PHP 会话进行会话存储,并且它们在所有参数上不一致,则最终可能会出现此错误。默认情况下,SimpleSAMLphp 使用 php.ini 中的设置,但可以在 config/config.php 中覆盖这些设置。
如果这是您错误的原因,您有两种选择:
然后No authentication source with id由于 simpleSAMLphp 和 codeIgniter 之间处理会话的冲突而发生错误。
解决方案是将 simpleSAMLphp 设置为使用 phpsession 以外的其他内容,因为Memcached存在问题,最好的方法是将其设置为“sql”。您可以在 simplesamlphp/config/config.php 中执行此操作:
/*
* Configure the datastore for simpleSAMLphp.
*
* - 'phpsession': Limited datastore, which uses the PHP session.
* - 'memcache': Key-value datastore, based on memcache.
* - 'sql': SQL datastore, using PDO.
*
* The default datastore is 'phpsession'.
*
* (This option replaces the old 'session.handler'-option.)
*/
'store.type' => 'sql',
Run Code Online (Sandbox Code Playgroud)
如果您决定使会话设置匹配,则应该更改 php.ini 中的设置。这是为了确保这些设置适用于使用默认设置的所有内容。php.ini 中的以下选项必须与应用程序使用的设置匹配:
- session.save_handler:这是用于存储会话的方法。默认为“文件”。
- session.save_path:这是保存会话文件的位置。默认值取决于您的 PHP 安装。
- session.name:这是会话 cookie 的名称。默认值为“PHPSESSID”。
- session.cookie_path:会话cookie限制的路径。默认值为“/”,这意味着它可用于您域中的所有页面。
- session.cookie_domain:这是会话 cookie 限制的域。默认未设置,这使得 cookie
仅对当前域可用。
请查看文档以获取更多信息
如果这仍然不起作用,作为最后的手段:尝试禁用清漆缓存
来源:
https://github.com/zl4bv/CakePHP-simpleSAMLphp-Plugin/issues/7
https://www.drupal.org/project/simplesamlphp_auth
| 归档时间: |
|
| 查看次数: |
571 次 |
| 最近记录: |