23 protected array $handlers = [];
43 $handler_string = $this->handlerService->describeCallable(
$handler);
44 if (!isset($this->handlers[$policy])) {
45 $this->handlers[$policy] = [];
48 $this->handlers[$policy][$handler_string] = [
50 'importance' => strtolower($importance),
65 $handler_string = $this->handlerService->describeCallable(
$handler);
67 unset($this->handlers[$policy][$handler_string]);
79 public function authenticate(
string $policy, array $authentication_params = []): bool {
80 if (!isset($this->handlers[$policy])) {
84 $authenticated =
false;
85 $first_exception = null;
87 foreach ($this->handlers[$policy] as $handler_string => $handler_config) {
88 $handler = $handler_config[
'handler'];
89 $importance = strtolower($handler_config[
'importance']);
91 if (!$this->handlerService->isCallable(
$handler)) {
92 $this->
getLogger()->warning(
"PAM handler '{$handler_string}' for policy '{$policy}' isn't callable");
96 $callable = $this->handlerService->resolveCallable(
$handler);
99 $result = call_user_func($callable, $authentication_params);
101 $authenticated =
true;
105 }
catch (\Exception $e) {
107 $e =
new AuthenticationException($e->getMessage(), $e->getCode(), $e);
110 if ($importance ===
'required') {
114 if (!isset($first_exception)) {
115 $first_exception = $e;
121 throw $first_exception;
124 return $authenticated;
Helpers for providing callable-based APIs.
Thrown by the AuthenticationService.
authenticate(string $policy, array $authentication_params=[])
Authenticate.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
unregisterHandler($handler, string $policy= 'user')
Unregister an authentication handler.
trait Loggable
Enables adding a logger.
__construct(protected HandlersService $handlerService)
Create new service.
registerHandler($handler, string $importance= 'sufficient', string $policy= 'user')
Register an authentication handler.
getLogger()
Returns logger.
Authentication service handles registration of PAM handlers and calling of those handlers.