aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/pam.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/pam.php')
-rw-r--r--engine/lib/pam.php48
1 files changed, 6 insertions, 42 deletions
diff --git a/engine/lib/pam.php b/engine/lib/pam.php
index f6db28355..1c9c3bfe1 100644
--- a/engine/lib/pam.php
+++ b/engine/lib/pam.php
@@ -20,6 +20,7 @@
* @subpackage Authentication.PAM
*/
+global $_PAM_HANDLERS;
$_PAM_HANDLERS = array();
/**
@@ -29,7 +30,9 @@ $_PAM_HANDLERS = array();
* failure, return false or throw an exception. Returning nothing indicates that
* the handler wants to be skipped.
*
- * @param string $handler The handler function in the format
+ * Note, $handler must be string callback (not an array/Closure).
+ *
+ * @param string $handler Callable global handler function in the format ()
* pam_handler($credentials = NULL);
* @param string $importance The importance - "sufficient" (default) or "required"
* @param string $policy The policy type, default is "user"
@@ -44,7 +47,8 @@ function register_pam_handler($handler, $importance = "sufficient", $policy = "u
$_PAM_HANDLERS[$policy] = array();
}
- if (is_callable($handler)) {
+ // @todo remove requirement that $handle be a global function
+ if (is_string($handler) && is_callable($handler, true)) {
$_PAM_HANDLERS[$policy][$handler] = new stdClass;
$_PAM_HANDLERS[$policy][$handler]->handler = $handler;
@@ -70,43 +74,3 @@ function unregister_pam_handler($handler, $policy = "user") {
unset($_PAM_HANDLERS[$policy][$handler]);
}
-
-function pam_authenticate($credentials = NULL, $policy = "user") {
- elgg_deprecated_notice('pam_authenticate has been deprecated for ElggPAM', 1.8);
- global $_PAM_HANDLERS, $_PAM_HANDLERS_MSG;
-
- $_PAM_HANDLERS_MSG = array();
-
- $authenticated = false;
-
- foreach ($_PAM_HANDLERS[$policy] as $k => $v) {
- $handler = $v->handler;
- $importance = $v->importance;
-
- try {
- // Execute the handler
- if ($handler($credentials)) {
- // Explicitly returned true
- $_PAM_HANDLERS_MSG[$k] = "Authenticated!";
-
- $authenticated = true;
- } else {
- $_PAM_HANDLERS_MSG[$k] = "Not Authenticated.";
-
- // If this is required then abort.
- if ($importance == 'required') {
- return false;
- }
- }
- } catch (Exception $e) {
- $_PAM_HANDLERS_MSG[$k] = "$e";
-
- // If this is required then abort.
- if ($importance == 'required') {
- return false;
- }
- }
- }
-
- return $authenticated;
-} \ No newline at end of file