diff --git a/classes/Authentication/SAML/XDSamlAuthentication.php b/classes/Authentication/SAML/XDSamlAuthentication.php index 40b19b9a69..f95a290b84 100644 --- a/classes/Authentication/SAML/XDSamlAuthentication.php +++ b/classes/Authentication/SAML/XDSamlAuthentication.php @@ -18,18 +18,18 @@ class XDSamlAuthentication protected $_as = null; /** - * Enumerated potential auth sources + * The selected auth source name (used for logout) * - * @var array + * @var string */ - protected $_sources = null; + protected $authSourceName = null; /** - * Whether or not SAML is configured. Defaults to false. + * Enumerated potential auth sources * - * @var boolean + * @var array */ - protected $_isConfigured = false; + protected $_sources = null; const BASE_ADMIN_EMAIL = <<_sources) !== false) { + $this->authSourceName = $authSource; $this->_as = new \SimpleSAML\Auth\Simple($authSource); } else { + $this->authSourceName = $this->_sources[0]; $this->_as = new \SimpleSAML\Auth\Simple($this->_sources[0]); } } @@ -84,10 +86,17 @@ public function __construct() */ public function isSamlConfigured() { - $this->_isConfigured = count($this->_sources) > 0 ? true : false; - return $this->_isConfigured; + return !empty($this->_sources); } + /** + * Logs out of the saml session + */ + public function logout(){ + if ($this->isSamlConfigured()) { + \SimpleSAML_Session::getSessionFromRequest()->doLogout($this->authSourceName); + } + } /** * Attempts to find a valid XDMoD user associated with the attributes we receive from SAML * @@ -97,7 +106,10 @@ public function isSamlConfigured() public function getXdmodAccount() { $samlAttrs = $this->_as->getAttributes(); - + /* + * SimpleSAMLphp uses its own session, this sets it back. + */ + \SimpleSAML_Session::getSessionFromRequest()->cleanup(); if ($this->_as->isAuthenticated()) { $userName = $samlAttrs['username'][0]; diff --git a/classes/XDSessionManager.php b/classes/XDSessionManager.php index 42a6720ae9..5bc2921fe5 100644 --- a/classes/XDSessionManager.php +++ b/classes/XDSessionManager.php @@ -133,6 +133,16 @@ public static function logoutUser($token = "") // authentication (via tokens) trip the first Exception as the // result of invoking resolveUserFromToken($token) session_destroy(); + + try { + $auth = new Authentication\SAML\XDSamlAuthentication(); + $auth->logout(); + } catch (InvalidArgumentException $ex) { + // This will catch when apache or nginx have been set up + // to to have an alternate saml configuration directory + // that does not exist, so we ignore it as saml isnt set + // up and we dont have to do anything with it + } } /** diff --git a/docs/simpleSAMLphp.md b/docs/simpleSAMLphp.md index 95d1525cbb..896ca887eb 100644 --- a/docs/simpleSAMLphp.md +++ b/docs/simpleSAMLphp.md @@ -47,10 +47,8 @@ You will need to modify the `config.php` file and make sure you modify the `meta ), ... ``` -two other keys that might need to be set if you are having errors +If you are having errors you might need to check the trusted domains setting ```php - ... - 'session.phpsession.cookiename' => null, ... 'trusted.url.domains' => array('f.q.dn.of.xdmod'), ... diff --git a/html/gui/general/login.php b/html/gui/general/login.php index 0cdbd0820e..cd3f5c0313 100644 --- a/html/gui/general/login.php +++ b/html/gui/general/login.php @@ -1,6 +1,6 @@ isSamlConfigured()) { @@ -50,7 +53,7 @@ function loadPortal() { setTimeout(function(){ parent.location.href = '/index.php' + document.location.hash; - }, 3000); + }, 1500); } function contactAdmin() { diff --git a/open_xdmod/modules/xdmod/integration_tests/scripts/samlSetup.sh b/open_xdmod/modules/xdmod/integration_tests/scripts/samlSetup.sh index 797a2fe536..e0a6af536b 100755 --- a/open_xdmod/modules/xdmod/integration_tests/scripts/samlSetup.sh +++ b/open_xdmod/modules/xdmod/integration_tests/scripts/samlSetup.sh @@ -136,7 +136,6 @@ sed -i -- 's%#%%' /etc/httpd/conf.d/xdmod.conf cp "$VENDOR_DIR/simplesamlphp/simplesamlphp/config-templates/config.php" "$VENDOR_DIR/simplesamlphp/simplesamlphp/config/config.php" sed -i -- "s/'trusted.url.domains' => array(),/'trusted.url.domains' => array('localhost:8080'),/" "$VENDOR_DIR/simplesamlphp/simplesamlphp/config/config.php" -sed -i -- "s/'session.phpsession.cookiename' => 'SimpleSAML',/'session.phpsession.cookiename' => null,/" "$VENDOR_DIR/simplesamlphp/simplesamlphp/config/config.php" cat > "$VENDOR_DIR/simplesamlphp/simplesamlphp/config/authsources.php" <