mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 11:26:13 +00:00
Auth, extend AuthenticationFactory to support getLastAuthProperties() from last authenticate() call. part of https://github.com/opnsense/core/issues/3266
This commit is contained in:
parent
b50fdd790c
commit
fc4a05da24
@ -36,6 +36,11 @@ use OPNsense\Core\Config;
|
||||
*/
|
||||
class AuthenticationFactory
|
||||
{
|
||||
/**
|
||||
* @var IAuthConnector|null last used authentication method in authenticate()
|
||||
*/
|
||||
var $lastUsedAuth = null;
|
||||
|
||||
/**
|
||||
* search already known local userDN's into simple mapping if auth method is current standard method
|
||||
* @param string $authserver auth server name
|
||||
@ -186,6 +191,7 @@ class AuthenticationFactory
|
||||
foreach ($service->supportedAuthenticators() as $authname) {
|
||||
$authenticator = $this->get($authname);
|
||||
if ($authenticator !== null) {
|
||||
$this->lastUsedAuth = $authenticator;
|
||||
if ($authenticator->authenticate($service->getUserName(), $password)) {
|
||||
if ($service->checkConstraints()) {
|
||||
syslog(LOG_NOTICE, sprintf(
|
||||
@ -252,4 +258,19 @@ class AuthenticationFactory
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* return authenticator properties from last authentication
|
||||
* @return array mixed named list of authentication properties
|
||||
*/
|
||||
public function getLastAuthProperties()
|
||||
{
|
||||
if ($this->lastUsedAuth != null) {
|
||||
return $this->lastUsedAuth->getLastAuthProperties();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user