Added config option to disable MFA globally

Added an option to disable MFA for all users and hide it from the login page and admin menu.
This commit is contained in:
KuJoe 2024-05-20 22:27:08 -04:00
commit 26d31f25da
5 changed files with 37 additions and 5 deletions

View file

@ -298,4 +298,7 @@ disablemfa = "Disable MFA"
enable_auto_save = "Enable Auto Save to Drafts" enable_auto_save = "Enable Auto Save to Drafts"
explain_autosave = "When enabled, new posts or pages will automatically be saved as a draft every 60 seconds after you start writing." explain_autosave = "When enabled, new posts or pages will automatically be saved as a draft every 60 seconds after you start writing."
login_protect_system = "Login protection system" login_protect_system = "Login protection system"
cloudflare_info = "Review Cloudflare's Turnstile documentation: " cloudflare_info = "Review Cloudflare's Turnstile documentation: "
mfa_config = "Multi Factor Authentication (MFA)"
set_mfa_globally = "Set the status of MFA"
explain_mfa = "When enabled, MFA is optional for all users. When disabled, no users can use it and it hides the field on the login page."

View file

@ -288,6 +288,30 @@
<input type="text" name="-config-social.youtube" class="form-control" id="social.youtube" value="<?php echo config('social.youtube');?>" placeholder="https://www.youtube.com/user/username"> <input type="text" name="-config-social.youtube" class="form-control" id="social.youtube" value="<?php echo config('social.youtube');?>" placeholder="https://www.youtube.com/user/username">
</div> </div>
</div> </div>
<br>
<h4><?php echo i18n('mfa_config');?></h4>
<hr>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('set_mfa_globally');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-mfa.state" id="mfa.state1" value="true" <?php if (config('mfa.state') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="mfa.state1">
<?php echo i18n('Enable');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-mfa.state" id="mfa.state2" value="false" <?php if (config('mfa.state') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="mfa.state2">
<?php echo i18n('Disable');?>
</label>
</div>
</div>
<small><em><?php echo i18n('explain_mfa');?></em></small>
</div>
</div>
<hr />
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-10"> <div class="col-sm-10">
<button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button> <button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button>

View file

@ -243,6 +243,7 @@ if (isset($_GET['search'])) {
</p> </p>
</a> </a>
</li> </li>
<?php if (config('mfa.state') === 'true'): ?>
<li class="nav-item"> <li class="nav-item">
<a href="<?php echo site_url();?>edit/mfa" class="nav-link"> <a href="<?php echo site_url();?>edit/mfa" class="nav-link">
<p> <p>
@ -250,6 +251,7 @@ if (isset($_GET['search'])) {
</p> </p>
</a> </a>
</li> </li>
<?php endif;?>
<li class="nav-item"> <li class="nav-item">
<a href="<?php echo site_url();?>edit/profile" class="nav-link"> <a href="<?php echo site_url();?>edit/profile" class="nav-link">
<p> <p>

View file

@ -21,9 +21,11 @@
} ?>" name="password" placeholder="<?php echo i18n('Password'); ?>"/> } ?>" name="password" placeholder="<?php echo i18n('Password'); ?>"/>
<br> <br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>"> <input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
<label><?php echo i18n('MFACode');?></label> <?php if (config('mfa.state') === 'true'): ?>
<input type="text" class="form-control" name="mfacode" placeholder="<?php echo i18n('verify_code'); ?>"/> <label><?php echo i18n('MFACode');?></label>
<br> <input type="text" class="form-control" name="mfacode" placeholder="<?php echo i18n('verify_code'); ?>"/>
<br>
<?php endif; ?>
<?php if (config('login.protect.system') === 'google'): ?> <?php if (config('login.protect.system') === 'google'): ?>
<script src='https://www.google.com/recaptcha/api.js'></script> <script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="<?php echo config("login.protect.public"); ?>"></div> <div class="g-recaptcha" data-sitekey="<?php echo config("login.protect.public"); ?>"></div>

View file

@ -87,5 +87,6 @@
"favicon.image", "favicon.image",
"views.root", "views.root",
"views.layout", "views.layout",
"autosave.enable" "autosave.enable",
"mfa.state"
] ]