Browse Source

changed admin-panel appearence to comply default admin-design

pull/7500/head
ManuA 2 weeks ago
parent
commit
c1325efe89
  1. 7
      .env.template
  2. 15
      src/api/core/two_factor/webauthn.rs
  3. 11
      src/config.rs
  4. 11
      src/static/templates/admin/settings.hbs

7
.env.template

@ -602,10 +602,9 @@
## Note that the checkbox would still be present, but ignored.
# DISABLE_2FA_REMEMBER=false
## WebAuthn 2FA user verification policy
## Valid values are "discouraged" and "preferred".
## Setting this to "preferred" allows clients to request PIN or biometric verification when supported by the authenticator.
# WEBAUTHN_2FA_USER_VERIFICATION=discouraged
## Set WebAuthn 2FA user verification to preferred
## When enabled, compatible authenticators can request PIN or biometric verification.
# WEBAUTHN_2FA_USER_VERIFICATION=false
##
## Authenticator Settings
## Disable authenticator time drifted codes to be valid.

15
src/api/core/two_factor/webauthn.rs

@ -45,13 +45,14 @@ static WEBAUTHN: LazyLock<Webauthn> = LazyLock::new(|| {
});
fn user_verification_policy() -> UserVerificationPolicy {
user_verification_policy_from_config(&CONFIG.webauthn_2fa_user_verification())
user_verification_policy_from_config(CONFIG.webauthn_2fa_user_verification())
}
fn user_verification_policy_from_config(value: &str) -> UserVerificationPolicy {
match value {
"preferred" => UserVerificationPolicy::Preferred,
_ => UserVerificationPolicy::Discouraged_DO_NOT_USE,
fn user_verification_policy_from_config(preferred: bool) -> UserVerificationPolicy {
if preferred {
UserVerificationPolicy::Preferred
} else {
UserVerificationPolicy::Discouraged_DO_NOT_USE
}
}
@ -537,11 +538,11 @@ mod tests {
#[test]
fn configured_user_verification_policy() {
assert_eq!(
serde_json::to_value(user_verification_policy_from_config("discouraged")).unwrap(),
serde_json::to_value(user_verification_policy_from_config(false)).unwrap(),
"discouraged"
);
assert_eq!(
serde_json::to_value(user_verification_policy_from_config("preferred")).unwrap(),
serde_json::to_value(user_verification_policy_from_config(true)).unwrap(),
"preferred"
);
}

11
src/config.rs

@ -712,8 +712,8 @@ make_config! {
/// Note that the checkbox would still be present, but ignored.
disable_2fa_remember: bool, true, def, false;
/// WebAuthn 2FA user verification |> Controls whether PIN or biometric user verification is discouraged or preferred for WebAuthn 2FA.
webauthn_2fa_user_verification: String, true, def, "discouraged".to_owned();
/// Set WebAuthn 2FA user verification to preferred |> Discouraged avoids requesting a PIN or biometric check for standard WebAuthn 2FA. Preferred asks compatible authenticators for user verification and can improve compatibility with some security keys.
webauthn_2fa_user_verification: bool, true, def, false;
/// Disable authenticator time drifted codes to be valid |> Enabling this only allows the current TOTP code to be valid
/// TOTP codes of the previous and next 30 seconds will be invalid.
@ -985,13 +985,6 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> {
err!("`DATABASE_MIN_CONNS` must be smaller than or equal to `DATABASE_MAX_CONNS`.");
}
match cfg.webauthn_2fa_user_verification.as_str() {
"discouraged" | "preferred" => (),
_ => err!(
"`WEBAUTHN_2FA_USER_VERIFICATION` is invalid. It needs to be one of the following options: discouraged or preferred"
),
}
if let Some(log_file) = &cfg.log_file
&& std::fs::OpenOptions::new().append(true).create(true).open(log_file).is_err()
{

11
src/static/templates/admin/settings.hbs

@ -26,16 +26,6 @@
{{#case type "text" "number" "password"}}
<label for="input_{{name}}" class="col-sm-3 col-form-label">{{doc.name}}</label>
<div class="col-sm-8">
{{#if (eq name "webauthn_2fa_user_verification")}}
<select class="form-select conf-text" id="input_{{name}}" name="{{name}}">
<option value="discouraged" {{#if (eq value "discouraged")}}selected{{/if}}>Discouraged</option>
<option value="preferred" {{#if (eq value "preferred")}}selected{{/if}}>Preferred</option>
</select>
<div class="form-text">
Discouraged avoids requesting a PIN or biometric check for standard WebAuthn 2FA.
Preferred asks compatible authenticators for user verification and can improve compatibility with some security keys.
</div>
{{else}}
<div class="input-group">
<input class="form-control conf-{{type}}" id="input_{{name}}" type="{{type}}"
name="{{name}}" value="{{value}}" {{#if default}} placeholder="Default: {{default}}"{{/if}}>
@ -43,7 +33,6 @@
<button class="btn btn-outline-secondary input-group-text" type="button" data-vw-pw-toggle="input_{{name}}">Show/hide</button>
{{/case}}
</div>
{{/if}}
</div>
{{/case}}
{{#case type "checkbox"}}

Loading…
Cancel
Save