Browse Source

CAS authentification configuration

Hubert Borderiou 13 năm trước cách đây
mục cha
commit
7a86cb95f0

+ 14 - 4
main/admin/user_add.php

@@ -128,14 +128,24 @@ if (api_get_setting('login_is_email') != 'true') {
 // Password
 $group = array();
 $auth_sources = 0; //make available wider as we need it in case of form reset (see below)
+$nb_ext_auth_source_added = 0;
 if (count($extAuthSource) > 0) {
-	$group[] =& HTML_QuickForm::createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2);
 	$auth_sources = array();
 	foreach($extAuthSource as $key => $info) {
-		$auth_sources[$key] = $key;
+	    // @todo : make uniform external authentification configuration (ex : cas and external_login ldap)
+	    // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
+	    // extAuthSource always on for CAS even if not activated
+	    // same action for file user_edit.php
+	    if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) {
+		    $auth_sources[$key] = $key;
+    		$nb_ext_auth_source_added++;
+		}
 	}
-	$group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources);
-	$group[] =& HTML_QuickForm::createElement('static', '', '', '<br />');
+	if ($nb_ext_auth_source_added > 0) {
+    	$group[] =& HTML_QuickForm::createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2);
+    	$group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources);
+    	$group[] =& HTML_QuickForm::createElement('static', '', '', '<br />');
+    }
 }
 $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword').'<br />', 1);
 $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', 'id="radio_user_password"', null, 0);

+ 16 - 5
main/admin/user_edit.php

@@ -158,15 +158,26 @@ if (api_get_setting('login_is_email') != 'true') {
 
 // Password
 $form->addElement('radio', 'reset_password', get_lang('Password'), get_lang('DontResetPassword'), 0);
+$nb_ext_auth_source_added = 0;
 if (count($extAuthSource) > 0) {
-	$group[] =& HTML_QuickForm::createElement('radio', 'reset_password', null, get_lang('ExternalAuthentication').' ', 3);
 	$auth_sources = array();
 	foreach($extAuthSource as $key => $info) {
-		$auth_sources[$key] = $key;
+	    // @todo : make uniform external authentification configuration (ex : cas and external_login ldap)
+	    // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
+	    // extAuthSource always on for CAS even if not activated
+	    // same action for file user_add.php
+	    if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) {
+    		$auth_sources[$key] = $key;
+    		$nb_ext_auth_source_added++;
+	    }
+	}
+	if ($nb_ext_auth_source_added > 0) {
+	    // @todo check the radio button for external authentification and select the external authentification in the menu
+	    $group[] =& HTML_QuickForm::createElement('radio', 'reset_password', null, get_lang('ExternalAuthentication').' ', 3);
+	    $group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources);
+	    $group[] =& HTML_QuickForm::createElement('static', '', '', '<br />');
+	    $form->addGroup($group, 'password', null, '', false);
 	}
-	$group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources);
-	$group[] =& HTML_QuickForm::createElement('static', '', '', '<br />');
-	$form->addGroup($group, 'password', null, '', false);
 }
 $form->addElement('radio', 'reset_password', null, get_lang('AutoGeneratePassword'), 1);
 $group = array();

+ 5 - 0
main/install/configuration.dist.php

@@ -87,6 +87,11 @@ $_configuration['db_admin_path']  = '';
 // $extAuthSource["ldap"]["login"]						= $_configuration['root_sys'].$_configuration['code_append']."auth/ldap/login.php";
 // $extAuthSource["ldap"]["newUser"]					= $_configuration['root_sys'].$_configuration['code_append']."auth/ldap/newUser.php";
 //
+// Go to Chamilo > Administration > CAS to activate CAS
+// You can leave these lines uncommented even if you don't use CAS
+$extAuthSource["cas"]["login"]						= $_configuration['root_sys'].$_configuration['code_append']."auth/cas/login.php";
+$extAuthSource["cas"]["newUser"]					= $_configuration['root_sys'].$_configuration['code_append']."auth/cas/newUser.php";
+//
 // To fetch external login information, uncomment those 2 lines and modify  files auth/external_login/newUser.php and auth/external_login/updateUser.php files
 // $extAuthSource["external_login"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.php";
 // $extAuthSource["external_login"]["updateUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/updateUser.php";

+ 6 - 6
plugin/add_cas_login_button/readme.txt

@@ -1,7 +1,7 @@
 README
-
-This plugin add a button to allow user to login to Chamilo with CAS authentification.
-You have to activate your CAS connection to display this button.
-You have to configure your CAS connection to have the button works.
-To activate and configure CAS, for your Chamilo platform, go to Administration > Configuration settings > CAS
-This plugin has been done to be added in the login_top region, but you can put it where you want.
+<br/><br/>
+This plugin add a button to allow user to login to Chamilo with CAS authentification.<br/><br/>
+You have to activate your CAS connection to display this button.<br/>
+You have to configure your CAS connection to have the button works.<br/>
+To activate and configure CAS, for your Chamilo platform, go to Administration > Configuration settings > CAS<br/>
+This plugin has been done to be added in the login_top region, but you can put it where you want.<br/>