OTP: generate longer secrets, also make them easier to read/copy
This commit is contained in:
parent
0b82afabd5
commit
0acd33abe3
|
@ -469,8 +469,8 @@ class Pref_Prefs extends Handler_Protected {
|
|||
<?= \Controls\hidden_tag("method", "otpenable") ?>
|
||||
|
||||
<fieldset>
|
||||
<label><?= __("OTP Key:") ?></label>
|
||||
<input dojoType='dijit.form.ValidationTextBox' disabled='disabled' value="<?= $otp_secret ?>" style='width : 215px'>
|
||||
<label><?= __("OTP secret:") ?></label>
|
||||
<code><?= $this->format_otp_secret($otp_secret) ?></code>
|
||||
</fieldset>
|
||||
|
||||
<!-- TODO: return JSON from the backend call -->
|
||||
|
@ -496,7 +496,7 @@ class Pref_Prefs extends Handler_Protected {
|
|||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<label><?= __("One time password:") ?></label>
|
||||
<label><?= __("Verification code:") ?></label>
|
||||
<input dojoType='dijit.form.ValidationTextBox' autocomplete='off' required='1' name='otp'>
|
||||
</fieldset>
|
||||
|
||||
|
@ -1518,4 +1518,8 @@ class Pref_Prefs extends Handler_Protected {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private function format_otp_secret($secret) {
|
||||
return implode(" ", str_split($secret, 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ class UserHelper {
|
|||
if ($user->otp_enabled) {
|
||||
$user->otp_secret = $salt_based_secret;
|
||||
} else {
|
||||
$user->otp_secret = bin2hex(get_random_bytes(6));
|
||||
$user->otp_secret = bin2hex(get_random_bytes(10));
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
|
|
@ -109,7 +109,7 @@ class Auth_Internal extends Auth_Base {
|
|||
<?= \Controls\hidden_tag("op", "login") ?>
|
||||
|
||||
<fieldset>
|
||||
<label><?= __("Please enter your one time password:") ?></label>
|
||||
<label><?= __("Please enter verification code (OTP):") ?></label>
|
||||
<input id="otp" dojoType="dijit.form.ValidationTextBox" required="1" autocomplete="off" size="6" name="otp" value=""/>
|
||||
<?= \Controls\submit_tag(__("Continue")) ?>
|
||||
</fieldset>
|
||||
|
|
Loading…
Reference in New Issue