SimpleSAML_Error_NoState: NOSTATE
Backtrace: 2 /home/jonesde/simplesamlphp/lib/SimpleSAML/Auth/State.php:263 (SimpleSAML_Auth_State::loadState) 1 /home/jonesde/simplesamlphp/modules/core/www/idp/resumelogout.php:6 (require) 0 /home/jonesde/public_html/saml/simplesaml/module.php:137 (N/A)
Hi Donovan,
On 5 Sep 2017, at 19:34 PM, doll...@gmail.com wrote:
> I finally figured this out. I hope this helps someone save days of troubleshooting.
>
> In the custom auth module I created based off the SSP example, in path: > lib > Auth > Source > External.php
>
> I had:
> session_unset();
> session_destroy();
>
> session_destroy was the problem.
Thanks for the feedback.
You shouldn’t be using the session_*() functions directly. Instead, you should use the SimpleSAML_Session class. How are you authenticating the user?
It doesn’t need to be set (as in available via $_SESSION), but it needs to exist (be there stored in the backend). Obviously, if the SimpleSAMLphp session is gone, there’s no way for the software to know who are you and where are you supposed to be logged out from. If you use session_destroy(), well, that literally destroys the session, making it impossible for SimpleSAMLphp to recover it later, and leading to missing state errors when trying to logout. If, on the other hand, you use session_unset(), the $_SESSION variable is unset but the session is not destroyed, so you don’t affect SSP’s session.
Remember also that SSP needs to have its own session completely separate from any other, so if you are looking for a particular session where to find authentication status, that *shouldn't* be SSP’s session. Since calling session_destroy() destroys SSP’s session, you are likely doing it wrong. You should commit & close the existing session (SSP’s), load the one where authentication status should be available (using named sessions), and then you can destroy it safely if you wish.
$newdata = array(
'auth_userid' => $aReturn['subscriberinfo']['saml_userid'],
'auth_customer_num' => $aReturn['subscriberinfo']['saml_customer_num'],
'auth_username' => $aReturn['subscriberinfo']['saml_username'],
'auth_password' => $aReturn['subscriberinfo']['saml_password'],
'auth_group' => $aReturn['subscriberinfo']['saml_group'],
'auth_brandcodes' => $aReturn['subscriberinfo']['saml_brandcodes'],
'auth_status' => $aReturn['subscriberinfo']['saml_status'],
'auth_sub_expire' => $aReturn['subscriberinfo']['saml_sub_expire'],
'auth_firstname' => $aReturn['subscriberinfo']['saml_firstname'],
'auth_lastname' => $aReturn['subscriberinfo']['saml_lastname'],
'auth_zip' => $aReturn['subscriberinfo']['saml_zip'],
'auth_phone' => $aReturn['subscriberinfo']['saml_phone'],
'auth_email' => $aReturn['subscriberinfo']['saml_email'],
'auth_lastlogin_dt' => date('Y-m-d H:i:s'),
'auth_lastmodified_dt' => date('Y-m-d H:i:s'),
'auth_lastmodby' => "login",
'auth_verify_code' => $aReturn['subscriberinfo']['saml_verifycode'],
'auth_verified' => $aReturn['subscriberinfo']['saml_verified'],
'auth_verified_dt' => $aReturn['subscriberinfo']['saml_verified_dt'],
'auth_name' => $vname
);
// set above info to $_SESSION
if( !isset( $_SESSION ) ) {
session_start();
}
foreach($newdata as $key => $value) {
$_SESSION[$key] = $value;
}
/*
* Option to override the default settings for the session cookie name
*/
'session.cookie.name' => 'SimpleSAMLSessionID',
/*
* Options to override the default settings for php sessions.
*/
'session.phpsession.cookiename' => 'SimpleSAML',
'session.phpsession.savepath' => null,
'session.phpsession.httponly' => true,
/*
* Option to override the default settings for the auth token cookie
*/
'session.authtoken.cookiename' => 'SimpleSAMLAuthToken',