Skip to content
This repository was archived by the owner on Jul 18, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

if (OCP\App::isEnabled('user_cas')) {

$CAS_DIR = OCP\Config::getSystemValue ( 'cas_dir', 'error' );

require_once 'user_cas/user_cas.php';

OCP\App::registerAdmin('user_cas', 'settings');
Expand All @@ -39,8 +41,13 @@
OCP\Util::connectHook('OC_User', 'post_login', 'OC_USER_CAS_Hooks', 'post_login');
OCP\Util::connectHook('OC_User', 'logout', 'OC_USER_CAS_Hooks', 'logout');

$force_login = shouldEnforceAuthentication();

// check if session is managed by cas or not
$isSessionManagedByCas = \OCP\App::isEnabled ( 'server_session_manager' );
$force_login=false;

if(!$isSessionManagedByCas){
$force_login = shouldEnforceAuthentication();
}
if( (isset($_GET['app']) && $_GET['app'] == 'user_cas') || $force_login ) {

if (OC_USER_CAS :: initialized_php_cas()) {
Expand All @@ -62,8 +69,8 @@
OC_Util::redirectToDefaultPage();
}


if (!phpCAS::isAuthenticated() && !OCP\User::isLoggedIn()) {
if (!phpCAS::isAuthenticated() && !OCP\User::isLoggedIn() && !$isSessionManagedByCas) {

// Load js code in order to render the CAS link and to hide parts of the normal login form
OCP\Util::addScript('user_cas', 'login');
Expand Down
18 changes: 15 additions & 3 deletions user_cas.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function __construct() {
$this->protectedGroups = explode (',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
$this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
$this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
$this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');

$this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
self :: initialized_php_cas();
}

Expand All @@ -84,15 +83,28 @@ public static function initialized_php_cas() {
if ($casDebugFile !== '') {
phpCAS::setDebug($casDebugFile);
}
phpCAS::client($casVersion,$casHostname,(int)$casPort,$casPath,false);
/**
* IMPORTANT @author:mcisse:
* PHP_CAS DOIT S'OCCUPER DE L'INITIALISATION DE LA SESSION SI ON VEUT QUE LE GLOBAL LOGOUT FONCTIONNE
*/
$isSessionManagedByCas = \OCP\App::isEnabled ( 'server_session_manager' );
phpCAS::client($casVersion,$casHostname,(int)$casPort,$casPath,$isSessionManagedByCas);
if(!empty($casCertPath)) {
phpCAS::setCasServerCACert($casCertPath);
}
else {
phpCAS::setNoCasServerValidation();
}
// Les hosts sont definies dans la config generale d'owncloud /config/config.php
$casRealHosts = OCP\Config::getSystemValue ('casRealHosts', array());
/**
* IMPORTANT @author:mcisse:
* PHP_CAS DOIT S'OCCUPER DE LA DESTRUCTION DE LA SESSION SI ON VEUT QUE LE GLOBAL LOGOUT FONCTIONNE
*/
phpCAS::handleLogoutRequests ( $isSessionManagedByCas, $casRealHosts );
self :: $_initialized_php_cas = true;
}

return self :: $_initialized_php_cas;
}

Expand Down