diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-10 08:32:16 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-10 08:32:16 +0000 |
commit | b0d3d96af7765ce1aff21a1a3ab19ffbb494363a (patch) | |
tree | 2cab87dba2eb687eec067a78468e2870b450c9c1 /engine/lib/api.php | |
parent | 4943b4e05e41d270a8c1448bcf82780ef5103c06 (diff) | |
download | elgg-b0d3d96af7765ce1aff21a1a3ab19ffbb494363a.tar.gz elgg-b0d3d96af7765ce1aff21a1a3ab19ffbb494363a.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Created PAM library
* API moved to use new PAM functions
git-svn-id: https://code.elgg.org/elgg/trunk@431 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/api.php')
-rw-r--r-- | engine/lib/api.php | 69 |
1 files changed, 2 insertions, 67 deletions
diff --git a/engine/lib/api.php b/engine/lib/api.php index 4eb1905b5..dccb703f8 100644 --- a/engine/lib/api.php +++ b/engine/lib/api.php @@ -615,76 +615,11 @@ } // PAM functions ////////////////////////////////////////////////////////////////////////// - - $PAM_HANDLERS = array(); - $PAM_HANDLER_MSG = array(); // Messages - - /** - * Register a method of authenticating an incoming API request. - * This function registers a PAM handler which is a function that matches the desciption pam_handler_name() - * and returns either 'true' if an incoming api request was authorised, false or throws an exception if not. - * - * The handlers are tried in turn until one of them successfully authenticates the session. - * - * This architecture lets an administrator choose what methods to accept for API authentication or - * - * @param unknown_type $handler - */ - function register_api_pam_handler($handler) - { - global $PAM_HANDLERS; - - if (is_callable($handler)) - { - $PAM_HANDLERS[$handler] = $handler; - return true; - } - - return false; - } - - /** - * Magically authenticate an API session using one of the registered methods. - * - * This function will return true if authentication was possible, otherwise it'll throw an exception. - * - * If $CONFIG->debug is set then additional debug information will be returned. - */ - function api_pam_authenticate() - { - global $PAM_HANDLERS, $PAM_HANDLER_MSG; - global $CONFIG; - - $dbg_msgs = array(); - foreach ($PAM_HANDLERS as $k => $v) - { - try { - // Execute the handler - if ($v()) - { - // Explicitly returned true - $PAM_HANDLER_MSG[$k] = "Authenticated!"; - - return true; - } - else - $PAM_HANDLER_MSG[$k] = "Not Authenticated."; - } - catch (Exception $e) - { - $PAM_HANDLER_MSG[$k] = "$e"; - } - } - - // Got this far, so no methods could be found to authenticate the session - throw new SecurityException("No authentication methods were found that could authenticate this request."); - } - /** * See if the user has a valid login sesson. */ - function pam_auth_session() + function pam_auth_session($credentials = NULL) { return isloggedin(); } @@ -692,7 +627,7 @@ /** * Secure authentication through headers and HMAC. */ - function pam_auth_hmac() + function pam_auth_hmac($credentials = NULL) { global $CONFIG; |