mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
CAS function Call
This commit is contained in:
parent
989fa91059
commit
6fcd19e3cb
1 changed files with 22 additions and 10 deletions
|
@ -1,25 +1,36 @@
|
||||||
<?PHP
|
<?PHP
|
||||||
// $Id: lib.php
|
// $Id: lib.php
|
||||||
// author: romualdLorthioir $
|
// author: romuald Lorthioir
|
||||||
//CHANGELOG:
|
//CHANGELOG:
|
||||||
|
//16/03/2005 Use of LDAP Module
|
||||||
//05.02.2005 Added CAS module
|
//05.02.2005 Added CAS module
|
||||||
|
|
||||||
/* README!
|
/* README!
|
||||||
CAS Module
|
CAS Module
|
||||||
This Module can be turn ON/OFF on admin screen.
|
This Module can be turn ON/OFF on admin screen.
|
||||||
The /login/index.php module is intercepted and replace with the login.php.
|
The /login/index.php module is intercepted and replace with the login.php.
|
||||||
And use the /auth/cas/index_form.html and /auth/cas/caslogin.php.
|
This Module is using the /auth/cas/index_form.html.
|
||||||
This module is using the LDAP Module so you need the /auth/ldap directory.
|
This module is using the LDAP Module so you need the /auth/ldap directory.
|
||||||
|
You can see /auth/ldap/lib.php for the other functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define('AUTH_LDAP_NAME', 'cas'); // for ldap module
|
||||||
require_once($CFG->dirroot.'/config.php');
|
require_once($CFG->dirroot.'/config.php');
|
||||||
include_once($CFG->dirroot.'/lib/cas/CAS.php');
|
require_once($CFG->dirroot.'/auth/ldap/lib.php');
|
||||||
|
require_once($CFG->dirroot.'/lib/cas/CAS.php');
|
||||||
$cas_validate=false;
|
$cas_validate=false;
|
||||||
define("AUTH_METHOD", 'cas');
|
|
||||||
require_once($CFG->dirroot.'/auth/cas/commonlib.php');
|
|
||||||
|
|
||||||
|
/**
|
||||||
function auth_user_login ($username, $password) {
|
* replace the ldap auth_user_login function
|
||||||
|
* authenticates user againt CAS with ldap
|
||||||
|
* Returns true if the username and password work
|
||||||
|
* and false if they don't
|
||||||
|
*
|
||||||
|
* @param string $username
|
||||||
|
* @param string $password
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function cas_ldap_auth_user_login ($username, $password) {
|
||||||
/// Returns true if the username and password work
|
/// Returns true if the username and password work
|
||||||
/// and false if they don't
|
/// and false if they don't
|
||||||
|
|
||||||
|
@ -28,7 +39,7 @@ function auth_user_login ($username, $password) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($CFG->auth == "cas" && !empty($CFG->cas_enabled)){
|
if ($CFG->auth == "cas" && !empty($CFG->cas_enabled)){ //cas specific
|
||||||
if ($CFG->cas_create_user=="0"){
|
if ($CFG->cas_create_user=="0"){
|
||||||
if (get_user_info_from_db("username", $username)){
|
if (get_user_info_from_db("username", $username)){
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,7 +66,7 @@ function auth_user_login ($username, $password) {
|
||||||
$ldap_login = ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
$ldap_login = ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
||||||
ldap_close($ldap_connection);
|
ldap_close($ldap_connection);
|
||||||
if ($ldap_login) {
|
if ($ldap_login) {
|
||||||
if ($CFG->cas_create_user=="0"){
|
if ($CFG->cas_create_user=="0"){ //cas specific
|
||||||
if (get_user_info_from_db("username", $username)){
|
if (get_user_info_from_db("username", $username)){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
@ -95,7 +106,7 @@ function cas_authenticate_user_login ($username, $password) {
|
||||||
}
|
}
|
||||||
if ($CFG->cas_create_user=="0"){
|
if ($CFG->cas_create_user=="0"){
|
||||||
if (get_user_info_from_db("username", phpCAS::getUser())){
|
if (get_user_info_from_db("username", phpCAS::getUser())){
|
||||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||||
}else{
|
}else{
|
||||||
//login as guest if CAS but not Moodle and not automatic creation
|
//login as guest if CAS but not Moodle and not automatic creation
|
||||||
if ($CFG->guestloginbutton){
|
if ($CFG->guestloginbutton){
|
||||||
|
@ -142,6 +153,7 @@ function cas_automatic_authenticate ($user="") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||||
}
|
}
|
||||||
return $user;
|
return $user;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue