简体   繁体   English

使用CakePHP的SimpleSAML-SimpleSAML_Error_NoState:NOSTATE

[英]SimpleSAML using CakePHP - SimpleSAML_Error_NoState: NOSTATE

I'm trying to configure SimpleSAMLPHP using CakePHP, in the project using just PHP it works fine but using CakePHP-simpleSAMLphp-Plugin I received the errors when I try to access the view : 我正在尝试使用CakePHP配置SimpleSAMLPHP,在仅使用PHP的项目中,它工作正常,但使用CakePHP-simpleSAMLphp-Plugin时,当我尝试访问视图时收到错误消息:

    Warning (4096): Argument 1 passed to SamlAuthenticate::unauthenticated() must be an instance of Controller, instance of CakeRequest given, called in C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\lib\Cake\Controller\Component\AuthComponent.php on line 348 and defined [APP\Plugin\Saml\Controller\Component\Auth\SamlAuthenticate.php, line 49]
    Warning (4096): Argument 1 passed to SamlComponent::login() must be an instance of mixed, none given, called in C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\app\Controller\UsersController.php on line 23 and defined [APP\Plugin\Saml\Controller\Component\SamlComponent.php, line 86]
    Notice (8): Undefined variable: url [APP\Plugin\Saml\Controller\Component\SamlComponent.php, line 87]
    Warning (4096): Argument 1 passed to SimpleSAML_Auth_Simple::login() must be of the type array, null given, called in C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\app\Plugin\Saml\Controller\Component\SamlComponent.php on line 87 and defined [C:\xampp\simplesaml\lib\SimpleSAML\Auth\Simple.php, line 100]
    Warning (2): array_key_exists() expects parameter 2 to be array, null given [C:\xampp\simplesaml\lib\SimpleSAML\Auth\Simple.php, line 102]
    Warning (2): array_key_exists() expects parameter 2 to be array, null given [C:\xampp\simplesaml\lib\SimpleSAML\Auth\Simple.php, line 108]
    Warning (2): array_key_exists() expects parameter 2 to be array, null given [C:\xampp\simplesaml\lib\SimpleSAML\Auth\Simple.php, line 110]
    Warning (2): array_key_exists() expects parameter 2 to be array, null given [C:\xampp\simplesaml\lib\SimpleSAML\Auth\Simple.php, line 120]
    Warning (2): Cannot modify header information - headers already sent by (output started at C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\lib\Cake\Utility\Debugger.php:801) [C:\xampp\simplesaml\lib\SimpleSAML\Utilities.php, line 585]
    Warning (2): Cannot modify header information - headers already sent by (output started at C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\lib\Cake\Utility\Debugger.php:801) [C:\xampp\simplesaml\lib\SimpleSAML\Utilities.php, line 588]
    Warning (2): Cannot modify header information - headers already sent by (output started at C:\Users\Alessandro\workspace\RW1\Projetos\Intranet\lib\Cake\Utility\Debugger.php:801) [C:\xampp\simplesaml\lib\SimpleSAML\Utilities.php, line 589]

Redirect   
You were redirected to: https://mysaml:9443/samlsso?...

And after the login I received the return : 在登录后,我收到了返回:

SimpleSAML_Error_NoState: NOSTATE
Backtrace:
2 C:\xampp\simplesaml\lib\SimpleSAML\Auth\State.php:225 (SimpleSAML_Auth_State::loadState)
1 C:\xampp\simplesaml\modules\saml\www\sp\saml2-acs.php:63 (require)
0 C:\xampp\simplesaml\www\module.php:134 (N/A)

I'm using CakePHP (2.5.2) and SimpleSAMLPHP (1.13.2) 我正在使用CakePHP(2.5.2)和SimpleSAMLPHP(1.13.2)

EDIT 编辑

This is the method unauthenticated(): 这是方法unauthenticated():

public function unauthenticated(Controller $controller) {
        return $this->Saml->isAuthenticated();
    }

This is var_dump of $controller : 这是$controller var_dump

object(CakeRequest)#9 (9) {
  ["params"]=>
  array(5) {
    ["plugin"]=>
    NULL
    ["controller"]=>
    string(5) "users"
    ["action"]=>
    string(5) "login"
    ["named"]=>
    array(0) {
    }
    ["pass"]=>
    array(0) {
    }
  }
  ["data"]=>
  array(0) {
  }
  ["query"]=>
  array(0) {
  }
  ["url"]=>
  string(11) "users/login"
  ["base"]=>
  string(22) "/Projeto"
  ["webroot"]=>
  string(23) "/Projeto/"
  ["here"]=>
  string(34) "/Projeto/users/login"
  ["_detectors":protected]=>
  array(11) {
    ["get"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(3) "GET"
    }
    ["post"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(4) "POST"
    }
    ["put"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(3) "PUT"
    }
    ["delete"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(6) "DELETE"
    }
    ["head"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(4) "HEAD"
    }
    ["options"]=>
    array(2) {
      ["env"]=>
      string(14) "REQUEST_METHOD"
      ["value"]=>
      string(7) "OPTIONS"
    }
    ["ssl"]=>
    array(2) {
      ["env"]=>
      string(5) "HTTPS"
      ["value"]=>
      int(1)
    }
    ["ajax"]=>
    array(2) {
      ["env"]=>
      string(21) "HTTP_X_REQUESTED_WITH"
      ["value"]=>
      string(14) "XMLHttpRequest"
    }
    ["flash"]=>
    array(2) {
      ["env"]=>
      string(15) "HTTP_USER_AGENT"
      ["pattern"]=>
      string(26) "/^(Shockwave|Adobe) Flash/"
    }
    ["mobile"]=>
    array(2) {
      ["env"]=>
      string(15) "HTTP_USER_AGENT"
      ["options"]=>
      array(26) {
        [0]=>
        string(7) "Android"
        [1]=>
        string(7) "AvantGo"
        [2]=>
        string(10) "BlackBerry"
        [3]=>
        string(6) "DoCoMo"
        [4]=>
        string(6) "Fennec"
        [5]=>
        string(4) "iPod"
        [6]=>
        string(6) "iPhone"
        [7]=>
        string(4) "iPad"
        [8]=>
        string(4) "J2ME"
        [9]=>
        string(4) "MIDP"
        [10]=>
        string(8) "NetFront"
        [11]=>
        string(5) "Nokia"
        [12]=>
        string(10) "Opera Mini"
        [13]=>
        string(10) "Opera Mobi"
        [14]=>
        string(6) "PalmOS"
        [15]=>
        string(10) "PalmSource"
        [16]=>
        string(9) "portalmmm"
        [17]=>
        string(7) "Plucker"
        [18]=>
        string(14) "ReqwirelessWeb"
        [19]=>
        string(12) "SonyEricsson"
        [20]=>
        string(7) "Symbian"
        [21]=>
        string(11) "UP\.Browser"
        [22]=>
        string(5) "webOS"
        [23]=>
        string(10) "Windows CE"
        [24]=>
        string(16) "Windows Phone OS"
        [25]=>
        string(5) "Xiino"
      }
    }
    ["requested"]=>
    array(2) {
      ["param"]=>
      string(9) "requested"
      ["value"]=>
      int(1)
    }
  }
  ["_input":protected]=>
  string(0) ""
}

And I tryied change to : 我尝试更改为:

public function unauthenticated(CakeRequest $controller) {
        $controller = $controller->params['controller'];
        return $this->Saml->isAuthenticated();
    }

The warning not happens but still not work. 该警告没有发生,但仍然无法正常工作。

Link of the resolution: https://github.com/zl4bv/CakePHP-simpleSAMLphp-Plugin/issues/7#issuecomment-63427478 该决议的链接: https : //github.com/zl4bv/CakePHP-simpleSAMLphp-Plugin/issues/7#issuecomment-63427478

I needed to change the type of session to 'sql' in config/config.php : 我需要在config/config.php中将会话类型更改为“ sql”:

'store.type' => 'sql',

And all works fine! 而且一切正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM