mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-30 01:36:27 +01:00
Support for YubiKey OTP 2 factor authenticator
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
## mm/dd/2022
|
## mm/dd/2022
|
||||||
|
|
||||||
1. [](#new)
|
1. [](#new)
|
||||||
|
* Support for `YubiKey OTP` 2-Factor authenticator
|
||||||
* New `elements` container field that shows/hides children fields based on boolean trigger value
|
* New `elements` container field that shows/hides children fields based on boolean trigger value
|
||||||
2. [](#improved)
|
2. [](#improved)
|
||||||
* Added new asset language strings
|
* Added new asset language strings
|
||||||
|
|||||||
@@ -278,8 +278,13 @@ class LoginController extends AdminController
|
|||||||
$code = $data['2fa_code'] ?? null;
|
$code = $data['2fa_code'] ?? null;
|
||||||
$secret = $user->twofa_secret ?? null;
|
$secret = $user->twofa_secret ?? null;
|
||||||
$redirect = (string)$this->getRequest()->getUri();
|
$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!');
|
Admin::DEBUG && Admin::addDebugMessage('Admin login: 2FA check failed, log out!');
|
||||||
|
|
||||||
// Failed 2FA auth, logout and redirect to the current page.
|
// Failed 2FA auth, logout and redirect to the current page.
|
||||||
|
|||||||
@@ -758,6 +758,9 @@ PLUGIN_ADMIN:
|
|||||||
2FA_SECRET: "2FA Secret"
|
2FA_SECRET: "2FA Secret"
|
||||||
2FA_SECRET_HELP: "Scan this QR code into your [Authenticator App](https://learn.getgrav.org/admin-panel/2fa#apps). Also it's a good idea to backup the secret in a safe location, in case you need to reinstall your app. Check the [Grav docs](https://learn.getgrav.org/admin-panel/2fa) for more information "
|
2FA_SECRET_HELP: "Scan this QR code into your [Authenticator App](https://learn.getgrav.org/admin-panel/2fa#apps). Also it's a good idea to backup the secret in a safe location, in case you need to reinstall your app. Check the [Grav docs](https://learn.getgrav.org/admin-panel/2fa) for more information "
|
||||||
2FA_REGENERATE: "Regenerate"
|
2FA_REGENERATE: "Regenerate"
|
||||||
|
YUBIKEY_ID: "YubiKey ID"
|
||||||
|
YUBIKEY_OTP_INPUT: "YubiKey OTP"
|
||||||
|
YUBIKEY_HELP: "Insert your YubiKey into your computer and click the button to generate an OTP. The first 12 chars are your client ID and will be saved."
|
||||||
FORCE_LOWERCASE_URLS: "Force lowercase URLs"
|
FORCE_LOWERCASE_URLS: "Force lowercase URLs"
|
||||||
FORCE_LOWERCASE_URLS_HELP: "By default Grav will set all slugs and routes to be lowercase. With this set to false, Uppercase slugs and routes can be used"
|
FORCE_LOWERCASE_URLS_HELP: "By default Grav will set all slugs and routes to be lowercase. With this set to false, Uppercase slugs and routes can be used"
|
||||||
INTL_ENABLED: "Intl module integration"
|
INTL_ENABLED: "Intl module integration"
|
||||||
|
|||||||
@@ -37,4 +37,9 @@ forms:
|
|||||||
id: twofa-code
|
id: twofa-code
|
||||||
autofocus: true
|
autofocus: true
|
||||||
placeholder: PLUGIN_ADMIN.2FA_CODE_INPUT
|
placeholder: PLUGIN_ADMIN.2FA_CODE_INPUT
|
||||||
|
description: or
|
||||||
|
yubikey_otp:
|
||||||
|
type: text
|
||||||
|
id: yubikey-otp
|
||||||
|
placeholder: PLUGIN_ADMIN.YUBIKEY_OTP_INPUT
|
||||||
---
|
---
|
||||||
|
|||||||
6
themes/grav/css-compiled/template.css
vendored
6
themes/grav/css-compiled/template.css
vendored
@@ -1912,6 +1912,12 @@ table.noflex {
|
|||||||
display: none; }
|
display: none; }
|
||||||
#admin-login .form-data {
|
#admin-login .form-data {
|
||||||
padding-right: 0; }
|
padding-right: 0; }
|
||||||
|
#admin-login .form-description {
|
||||||
|
display: block;
|
||||||
|
margin-top: -15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 110%; }
|
||||||
#admin-login .wrapper-spacer {
|
#admin-login .wrapper-spacer {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -57,6 +57,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
@include flex(1);
|
@include flex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-field {
|
.form-field {
|
||||||
@@ -72,6 +73,14 @@
|
|||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-description {
|
||||||
|
display: block;
|
||||||
|
margin-top: -15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 110%;
|
||||||
|
}
|
||||||
|
|
||||||
.wrapper-spacer {
|
.wrapper-spacer {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
|
|||||||
Reference in New Issue
Block a user