-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63c828b
commit 7419da6
Showing
4 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2023 Micke Nordin <[email protected]> | ||
* @copyright Copyright (c) 2023-2024 Micke Nordin <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* @author Micke Nordin <[email protected]> | ||
|
@@ -28,6 +28,7 @@ | |
|
||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\IAppConfig; | ||
use OCP\IUser; | ||
use OCP\ISession; | ||
use OCP\User\Events\UserLoggedInEvent; | ||
|
@@ -39,11 +40,12 @@ | |
* | ||
* @package OCA\StepUpAuth\Events | ||
*/ | ||
class UserLoggingIn implements IEventListener | ||
class UserLoggedIn implements IEventListener | ||
{ | ||
public function __construct( | ||
private ISession $session, | ||
private LoggerInterface $logger | ||
private LoggerInterface $logger, | ||
private IAppConfig $config | ||
) { | ||
} | ||
|
||
|
@@ -60,6 +62,15 @@ public function handle(Event $event): void | |
* @var IUser $user | ||
*/ | ||
$user = $event->getUser(); | ||
$mfaVerified = '0'; | ||
$mfa_key = 'urn:oid:2.5.4.2'; // TODO: get from config | ||
$attr = $this->session->get('user_saml.samlUserData'); | ||
if (isset($mfa_key) && isset($attr[$mfa_key])) { | ||
$mfaVerified = $attr[$mfa_key][0]; | ||
} | ||
if ($mfaVerified == '1') { | ||
return; | ||
} | ||
$this->logger->debug('StepUpAuth running', ['app' => 'stepupauth']); | ||
$this->session->set('two_factor_auth_uid', $user->getUID()); | ||
$this->session->set('two_factor_remember_login', true); | ||
|