Support for YubiKey OTP 2 factor authenticator

This commit is contained in:
Andy Miller
2022-01-11 12:00:10 -07:00
parent c763004a94
commit 0f05d065b0
7 changed files with 31 additions and 2 deletions

View File

@@ -278,8 +278,13 @@ class LoginController extends AdminController
$code = $data['2fa_code'] ?? null;
$secret = $user->twofa_secret ?? null;
$redirect = (string)$this->getRequest()->getUri();
$twofa_valid = $twoFa->verifyCode($secret, $code);
if (null === $twoFa || !$user->authenticated || !$code || !$secret || !$twoFa->verifyCode($secret, $code)) {
$yubikey_otp = $data['yubikey_otp'] ?? null;
$yubikey_id = $user->yubikey_id ?? null;
$yubikey_valid = $twoFa->verifyYubikeyOTP($yubikey_id, $yubikey_otp);
if (null === $twoFa || !$user->authenticated || (!$twofa_valid && !$yubikey_valid) ) {
Admin::DEBUG && Admin::addDebugMessage('Admin login: 2FA check failed, log out!');
// Failed 2FA auth, logout and redirect to the current page.