zl4bv / CakePHP-simpleSAMLphp-Plugin

Adds support for SAML authentication to CakePHP 2.x.
12 stars 8 forks source link

SimpleSAML_Error_NoState: NOSTATE after login #7

Closed alessandrogviana closed 9 years ago

alessandrogviana commented 9 years ago

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)

zl4bv commented 9 years ago

I have a fix for the first issue you see, but very stumped on the second issue. I'm trying the same versions of CakePHP and SimpleSamlPHP as you and seem to be getting the same error when I return from a SAML login - still working on why. Will post back when I find something.

zl4bv commented 9 years ago

Ok, so it looks like it is caused by conflicting sessions between CakePHP and SimpleSamlPHP. From what I have read here (see the note in the prerequisites section), you will need to config SimpleSamlPHP to store session information using a method other than phpsession.

Here is the relevant config in 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',