0

我正在尝试使用 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?...

登录后我收到了回报:

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)

我正在使用 CakePHP (2.5.2) 和 SimpleSAMLPHP (1.13.2)

编辑

这是未经身份验证的方法():

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

var_dump$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) ""
}

我尝试更改为:

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

警告没有发生但仍然不起作用。

4

1 回答 1

0

决议链接: https ://github.com/zl4bv/CakePHP-simpleSAMLphp-Plugin/issues/7#issuecomment-63427478

我需要将会话类型更改为“sql” config/config.php

'store.type' => 'sql',

一切正常!

于 2014-11-19T13:38:33.600 回答