skala
Julio Montoya 13 years ago
commit d667c55921
  1. 22
      main/auth/cas/authcas.php
  2. 16
      main/auth/cas/logincas.php
  3. 2
      main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
  4. 7
      plugin/add_cas_login_button/index.php
  5. 12
      plugin/add_cas_login_button/template.tpl

@ -9,18 +9,38 @@ require_once(api_get_path(SYS_PATH).'main/auth/cas/cas_var.inc.php');
require_once(api_get_path(SYS_PATH).'main/auth/external_login/ldap.inc.php');
require_once(api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php');
/**
* @return true if cas is configured
*
**/
function cas_configured() {
global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
$res = false;
if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) {
$res = true;
}
return $res;
}
/**
* checks if the user already get a session
* @return the user login if the user already has a session ,false otherwise
**/
function cas_is_authenticated()
{
global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
global $PHPCAS_CLIENT;
global $logout;
if (!cas_configured()) {
return;
}
if (!is_object($PHPCAS_CLIENT) )
{

@ -16,9 +16,15 @@ require_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php');
require_once('authcas.php');
global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
// phpCAS
if (!is_object($PHPCAS_CLIENT) ) {
phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
phpCAS::setNoCasServerValidation();
if (cas_configured()) {
if (!is_object($PHPCAS_CLIENT) ) {
phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
phpCAS::setNoCasServerValidation();
}
phpCAS::forceAuthentication();
header('Location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login'));
}
else {
header('Location: '.api_get_path(WEB_PATH));
}
phpCAS::forceAuthentication();
header('Location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login'));

@ -24,7 +24,7 @@ ALTER TABLE user_friend RENAME TO user_rel_user;
ALTER TABLE session_rel_user ADD COLUMN relation_type int NOT NULL default 0;
ALTER TABLE course_rel_user ADD COLUMN relation_type int NOT NULL default 0;
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook',1,0);
-- see #4705 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook',1,0);
ALTER TABLE course DROP PRIMARY KEY , ADD UNIQUE KEY code (code);
ALTER TABLE course ADD id int NOT NULL auto_increment PRIMARY KEY FIRST;
CREATE TABLE block (id INT NOT NULL auto_increment, name VARCHAR(255) NULL, description TEXT NULL, path VARCHAR(255) NOT NULL, controller VARCHAR(100) NOT NULL, active TINYINT NOT NULL default 1, PRIMARY KEY(id));

@ -1,9 +1,12 @@
<?php
// Show the CAS button to login using CAS
require_once(api_get_path(SYS_PATH).'main/auth/cas/authcas.php');
$_template['show_message'] = false;
if (api_is_anonymous() && api_get_setting('cas_activate') == 'true') {
if (api_is_anonymous()) {
$_template['cas_activated'] = api_is_cas_activated();
$_template['cas_configured'] = cas_configured();
$_template['show_message'] = true;
// the default title
$button_label = "Connexion via CAS";
@ -18,4 +21,4 @@ if (api_is_anonymous() && api_get_setting('cas_activate') == 'true') {
$_template['button_label'] = $button_label;
$_template['comm_label'] = $comm_label;
$_template['url_label'] = $url_label;
}
}

@ -24,7 +24,7 @@
4. Read more
You can also see more examples in the the main/template/default/layout files
5. {$_p|var_dump} pour les path {$_u|var_dump} pour info de l'utilisateur loggé
5. {$_p|var_dump} pour les path {$_u|var_dump} pour info de l'utilisateur loggé
#}
@ -39,6 +39,14 @@
<div class='cas_plugin_clear'>&nbsp;</div>
{% endif %}
<div class='cas_plugin_comm'>{{add_cas_login_button.comm_label}}</div>
<button class="btn" onclick="javascript:self.location.href='main/auth/cas/logincas.php'">{{"LoginEnter"|get_lang}}</button>
{% if add_cas_login_button.cas_activated %}
{% if add_cas_login_button.cas_configured %}
<button class="btn" onclick="javascript:self.location.href='main/auth/cas/logincas.php'">{{"LoginEnter"|get_lang}}</button>
{% else %}
CAS isn't configured. Go to Admin > Configuration > CAS.<br/>
{% endif %}
{% else %}
CAS isn't activated. Go to Admin > Configuration > CAS.<br/>
{% endif %}
</div>
{% endif %}

Loading…
Cancel
Save