SSOCircle保持重定向到Consent页面SAML2.0

时间:2018-03-10 04:34:38

标签: php codeigniter saml saml-2.0 simplesamlphp

我正在使用SSOCircle使用Codeigniter测试我的SAML实现。目前的步骤是:

  1. 访问website.com
  2. 重定向到SSOCircle同意页
  3. 验证身份
  4. 将用户数据传回website.com
  5. 然而,在步骤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);
            }
        }
    

    我认为我的重定向可能是它继续调用同意页面的原因。但是,添加了另一个URL以便使用此功能进行访问

    public function auth(){
            $attributes = $auth->getAttributes();
            var_dump($attributes);
    }
    

    我收到此错误:

    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)
    

    我希望有人可以看看这个并帮助我。谢谢。

    更新:

    我最近注意到SSOCircle实际上返回到我的登录页面。但是,它会立即将其重定向回SSOCircle页面。不确定这是否有帮助

    NULL 重定向 您被重定向到:https://idp.ssocircle.com:443/sso/SSORedirect/metaAlias/publicidp?SAMLRequest=vVPBjtowEP2VyPfghCQqWIDELqoWabeLCO1hLytjD4ulxHY9k6X8fZ2kVbc9cOzJ0vO8N%2B%2FN2AuUbePFuqOz3cP3DpCSH21jUQwXS9YFK5xEg8LKFlCQEvX66VFMJ5nwwZFTrmEfKLcZEhECGWdZst0s2WtWgNafINe5UlrqY1lJmE1BlvOimkN10mVWZZDn85wl3yBgZC5ZFIp0xA62FklailCWz9KsSPP8kM1EVYqqeGHJJqYxVtLAOhN5FJwb7SeITpmgGpgo14qyLHhEeF0%2F70GbAIp4CyTXjZHIfXdsjIoslqx%2Fu793FrsWQg3h3Sj4un%2F8o6%2FhfRJdBe0UpjgWYN%2BH7x%2FuniCoLly59D6KDs44nU3Qr14GunI0rW%2BgnyO%2FXC68dbqLJv3Z8wHD8ZymUuGAajjJrqEUo7vdr23cGauNfbu9iONYhOLhcNilu%2Bf6wFaLXlsMgw2r%2FxSnn7OWJP9Js%2BAfvSzGR%2Folpthudi62uiafXWgl3Q7ZI0anp6FUUJAWDViKi2wad7kPIAmWjEIHjK%2FGln9%2FhdVP&RelayState=https%3A%2F%2Fwww.website.com%2Fapp

    UPDATE2:我刚检查了日志,并收到了此警告

    Mar 12 23:26:26 simplesamlphp WARNING [da20d4a7a3] Could not load state specified by InResponseTo: NOSTATE Processing response as unsolicited.
    

    我被告知这是因为失去了国家信息。但是我检查了我的cookie名称并且它们匹配。我还错过了什么?

    https://github.com/simplesamlphp/simplesamlphp/wiki/State-Information-Lost

1 个答案:

答案 0 :(得分:3)

<强>更新 后续段落假设当您修改代码以避免重定向时,您已确保:

Configure the authentication module:**

  

在unix上,这可以通过运行(来自SimpleSAMLphp)来完成   安装目录):

touch modules/exampleauth/enable
     

下一步是使用此模块创建身份验证源。   认证源是具有特定的认证模块   组态。每个身份验证源都有一个名称,用于   请参阅IdP配置中的此特定配置。   可以在中找到身份验证源的配置   配置/ authsources.php。

     

在此设置中,此文件应包含单个条目:

<?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用于student-user。   每个用户的属性在引用的数组中配置   指数。对于学生用户,这些是:

array(
    'uid' => array('student'),
    'eduPersonAffiliation' => array('member', 'student'),
),
     

当用户登录时,IdP将返回属性。

     

应用程序的PHP会话设置与SimpleSAMLphp不匹配

     

如果您尝试将SAML 2.0支持添加到和   SimpleSAMLphp使用PHP会话进行会话存储,但他们没有   同意所有参数,您最终可能会遇到此错误。通过   默认情况下,SimpleSAMLphp使用php.ini中的设置,但这些可以   在config / config.php中重写。

     

如果这是导致错误的原因,您有两种选择:

然后由于处理simpleSAMLphp和codeIgniter之间的会话冲突而发生No authentication source with id错误。

解决方案1:将SimpleSAMLphp更改为使用不同的会话存储方法

解决方案是将simpleSAMLphp设置为使用除了phpsession之外的其他内容,因为Memcached存在问题,最好的方法是将其设置为“sql&#39;”。你可以在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',

解决方案2:更改会话设置以匹配应用程序和SimpleSAMLphp:

如果您决定使会话设置匹配,则应更改php.ini中的设置。这是为了确保设置适用于使用默认设置的所有内容。 php.ini中的以下选项必须与应用程序使用的设置匹配:

  
      
  • session.save_handler:这是用于存储会话的方法。默认为&#34;文件&#34;。
  •   
  • session.save_path:这是会话文件的保存位置。默认值取决于您的PHP安装。
  •   
  • session.name:这是会话cookie的名称。默认值为&#34; PHPSESSID&#34;。
  •   
  • session.cookie_path:会话cookie限制的路径。默认值为&#34; /&#34;,这意味着它可供所有人使用   您网域上的网页。
  •   
  • session.cookie_domain:这是会话cookie限定的域。默认设置为unset,这使得cookie可用   仅限当前域名。
  •   

请查看the docs了解更多信息

如果仍然不起作用,作为最后的手段:try disabling varnish caching

来源:
https://github.com/zl4bv/CakePHP-simpleSAMLphp-Plugin/issues/7 https://www.drupal.org/project/simplesamlphp_auth

相关问题