Skip to content

Commit

Permalink
Made the TOTP URL visible during setup
Browse files Browse the repository at this point in the history
Useful for some non-scanner type apps.
Closes #2908
  • Loading branch information
ssddanbrown committed Sep 1, 2021
1 parent ff494be commit 7028025
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/MfaTotpController.php
Expand Up @@ -35,8 +35,8 @@ public function generate(TotpService $totp)
$svg = $totp->generateQrCodeSvg($qrCodeUrl);

return view('mfa.totp-generate', [
'secret' => $totpSecret,
'svg' => $svg,
'url' => $qrCodeUrl,
'svg' => $svg,
]);
}

Expand Down
1 change: 1 addition & 0 deletions resources/sass/_layout.scss
Expand Up @@ -145,6 +145,7 @@ body.flexbox {
.flex {
min-height: 0;
flex: 1;
max-width: 100%;
&.fit-content {
flex-basis: auto;
flex-grow: 0;
Expand Down
3 changes: 3 additions & 0 deletions resources/views/mfa/totp-generate.blade.php
Expand Up @@ -12,6 +12,9 @@
<div class="block inline">
{!! $svg !!}
</div>
<div class="code-base small text-muted px-s py-xs my-xs" style="overflow-x: scroll; white-space: nowrap;">
{{ $url }}
</div>
</div>

<h2 class="list-heading">{{ trans('auth.mfa_gen_totp_verify_setup') }}</h2>
Expand Down
4 changes: 3 additions & 1 deletion tests/Auth/MfaConfigurationTest.php
Expand Up @@ -36,10 +36,12 @@ public function test_totp_setup()
$resp->assertSee('The provided code is not valid or has expired.');
$revisitSvg = $resp->getElementHtml('#main-content .card svg');
$this->assertTrue($svg === $revisitSvg);
$secret = decrypt(session()->get('mfa-setup-totp-secret'));

$resp->assertSee(htmlentities("?secret={$secret}&issuer=BookStack&algorithm=SHA1&digits=6&period=30"));

// Successful confirmation
$google2fa = new Google2FA();
$secret = decrypt(session()->get('mfa-setup-totp-secret'));
$otp = $google2fa->getCurrentOtp($secret);
$resp = $this->post('/mfa/totp/confirm', [
'code' => $otp,
Expand Down

0 comments on commit 7028025

Please sign in to comment.