Add option for auth hook optionality - patch from Wolfgang Herget.

This commit is contained in:
Andrew McMillan 2009-10-06 18:17:17 +13:00
parent 1ff298c42b
commit a4aedbef05
2 changed files with 12 additions and 1 deletions

View File

@ -162,6 +162,9 @@ $c->collections_always_exist = false;
* and he used to authenticate the user should be at least 'password,user_no'
* awl/inc/AuthPlugins.php is a sample file not used by showing what could be
* a hook
*
* $c->authenticate_hook['optional'] = true; can be set to try default authentication
* as well in case the configured hook should report a failure.
*/
/********************************/

View File

@ -221,7 +221,15 @@ class HTTPAuthSession {
* It can expect that:
* - Configuration data will be in $c->authenticate_hook['config'], which might be an array, or whatever is needed.
*/
return call_user_func( $c->authenticate_hook['call'], $username, $password );
$hook_response = call_user_func( $c->authenticate_hook['call'], $username, $password );
/**
* make the authentication hook optional: if the flag is set, ignore a return value of 'false'
*/
if (isset($c->authenticate_hook['optional']) && $c->authenticate_hook['optional']) {
if ($hook_response !== false) { return $hook_response; }
} else {
return $hook_response;
}
}
if ( $usr = getUserByName($username) ) {