mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-29 09:16:48 +01:00
Support for YubiKey OTP 2 factor authenticator
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user