Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/concerns/user_otp_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_direct_otp
end

def generate_totp_secret
ROTP::Base32.random(20)
ROTP::Base32.random(20) # 160-bit secret, per RFC 4226
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not technically related but it was a comment I had before #5604 (comment)

end

def authenticate_direct_otp(code)
Expand Down
22 changes: 10 additions & 12 deletions app/views/users/totp_setup/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@
<%= image_tag @qrcode, skip_pipeline: true, alt: t('image_description.totp_qrcode') %>
</div>
<%= t('instructions.mfa.authenticator.manual_entry') %>
<div class="grid-row margin-top-2 flex-align-center">
<code class="grid-col-fill font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
<%= @code %>
</code>
<%= render ClipboardButtonComponent.new(
clipboard_text: @code.upcase,
outline: true,
class: 'margin-right-0 margin-top-2 mobile-lg:margin-top-0 mobile-lg:margin-left-2 ico ico-copy',
) do %>
<%= t('links.copy') %>
<% end %>
</div>
<code class="display-block margin-y-2 font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
<%= @code %>
</code>
<%= render ClipboardButtonComponent.new(
clipboard_text: @code.upcase,
outline: true,
class: 'ico ico-copy',
) do %>
<%= t('links.copy') %>
<% end %>
</div>
</li>
<li class="padding-y-2 border-top border-primary-light">
Expand Down
2 changes: 1 addition & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
end

describe '#generate_totp_secret' do
it 'generates a secret 16 characters long' do
it 'generates a secret 32 characters long' do
user = build(:user)
secret = user.generate_totp_secret
expect(secret.length).to eq 32
Expand Down