|
Revision 975, 2.3 kB
(checked in by misja, 2 years ago)
|
New ini based authentication plugin to handle multiple authentication handlers.
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
function multiple_authenticate_user_login($username, $password) |
|---|
| 26 |
{ |
|---|
| 27 |
global $CFG, $messages; |
|---|
| 28 |
|
|---|
| 29 |
$auth_config = null; |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
if(!$CFG->auth_multiple_ini) |
|---|
| 33 |
{ |
|---|
| 34 |
$messages[] = 'No "auth.ini" location defined'; |
|---|
| 35 |
|
|---|
| 36 |
return false; |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
if (!file_exists($CFG->auth_multiple_ini)) |
|---|
| 41 |
{ |
|---|
| 42 |
$messages[] = 'File "auth.ini" does not exist'; |
|---|
| 43 |
|
|---|
| 44 |
return false; |
|---|
| 45 |
} |
|---|
| 46 |
else |
|---|
| 47 |
{ |
|---|
| 48 |
|
|---|
| 49 |
$auth_config = parse_ini_file($CFG->auth_multiple_ini, true); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
foreach ($auth_config as $key => $settings) |
|---|
| 54 |
{ |
|---|
| 55 |
|
|---|
| 56 |
foreach ($settings as $setting => $value) |
|---|
| 57 |
{ |
|---|
| 58 |
$CFG->{$setting} = $value; |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
require_once($CFG->dirroot . "auth/$CFG->auth/lib.php"); |
|---|
| 63 |
|
|---|
| 64 |
$function = $CFG->auth . "_authenticate_user_login"; |
|---|
| 65 |
|
|---|
| 66 |
$result = $function($username, $password); |
|---|
| 67 |
|
|---|
| 68 |
if ($result == false) |
|---|
| 69 |
{ |
|---|
| 70 |
continue; |
|---|
| 71 |
} |
|---|
| 72 |
else |
|---|
| 73 |
{ |
|---|
| 74 |
|
|---|
| 75 |
return $result; |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
// so we use the internal authentication code as a final resort |
|---|
| 81 |
|
|---|
| 82 |
// Reset to internal |
|---|
| 83 |
$CFG->auth = 'internal'; |
|---|
| 84 |
|
|---|
| 85 |
require_once($CFG->dirroot . "auth/internal/lib.php"); |
|---|
| 86 |
|
|---|
| 87 |
return internal_authenticate_user_login($username, $password); |
|---|
| 88 |
} |
|---|
| 89 |
?> |
|---|
| 90 |
|
|---|