Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MFA and Silent Logins #43790

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions plugins/system/webauthn/src/PluginTraits/AjaxHandlerLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,18 @@ class_exists('Joomla\\CMS\\Authentication\\Authentication', true);
}

// Run the user plugins. They CAN block login by returning boolean false and setting $response->error_message.
PluginHelper::importPlugin('user');
$eventClassName = self::getEventClassByEventName('onUserLogin');
$event = new $eventClassName('onUserLogin', [(array) $response, $options]);
$result = $this->getApplication()->getDispatcher()->dispatch($event->getName(), $event);
$dispatcher = $this->getApplication()->getDispatcher();

PluginHelper::importPlugin('user', null, true, $dispatcher);

$event = new \Joomla\CMS\Event\User\LoginEvent(
'onUserLogin',
[
'options' => $options,
'subject' => (array) $response,
]
);
$result = $dispatcher->dispatch('onUserLogin', $event);
$results = !isset($result['result']) || \is_null($result['result']) ? [] : $result['result'];

// If there is no boolean FALSE result from any plugin the login is successful.
Expand All @@ -213,17 +221,27 @@ class_exists('Joomla\\CMS\\Authentication\\Authentication', true);
$options['responseType'] = $response->type;

// The user is successfully logged in. Run the after login events
$eventClassName = self::getEventClassByEventName('onUserAfterLogin');
$event = new $eventClassName('onUserAfterLogin', [$options]);
$this->getApplication()->getDispatcher()->dispatch($event->getName(), $event);
$event = new \Joomla\CMS\Event\User\AfterLoginEvent(
'onUserAfterLogin',
[
'options' => $options,
'subject' => (array) $response,
]
);
$dispatcher->dispatch($event->getName(), $event);

return;
}

// If we are here the plugins marked a login failure. Trigger the onUserLoginFailure Event.
$eventClassName = self::getEventClassByEventName('onUserLoginFailure');
$event = new $eventClassName('onUserLoginFailure', [(array) $response]);
$this->getApplication()->getDispatcher()->dispatch($event->getName(), $event);
$event = new \Joomla\CMS\Event\User\LoginFailureEvent(
'onUserLoginFailure',
[
'options' => $options,
'subject' => (array) $response,
]
);
$dispatcher->dispatch('onUserLoginFailure', $event);

// Log the failure
Log::add($response->error_message, Log::WARNING, 'jerror');
Expand Down