Fix the storing of cached credentials when an authentication hook is used.

Thank you LDAP tests for picking up this issue!
This commit is contained in:
Andrew Ruthven 2022-12-19 23:05:11 +13:00
parent 521594bc3f
commit 0b709c791d

View File

@ -368,11 +368,14 @@ class HTTPAuthSession {
* - Configuration data will be in $c->authenticate_hook['config'], which might be an array, or whatever is needed.
*/
$principal = call_user_func( $c->authenticate_hook['call'], $username, $password );
if ( $principal !== false && !($principal instanceof Principal) ) {
$principal = new Principal('username', $username);
}
if ( $principal === false ) {
$this->SetCache($username, $password, 'fail');
} else if (!($principal instanceof Principal) ) {
} else {
$this->SetCache($username, $password, 'pass');
$principal = new Principal('username', $username);
}
return $principal;