doulan7166 2014-11-17 12:59
浏览 87
已采纳

使用CakePHP的SimpleSAML - 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 :

    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)

EDIT

This is the method unauthenticated():

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

This is var_dump of $controller :

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.

  • 写回答

1条回答 默认 最新

  • doubanduo7620 2014-11-19 13:38
    关注

    Link of the resolution: 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:

    'store.type' => 'sql',
    

    And all works fine!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?