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_base32(16)
ROTP::Base32.random(20)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if we left a comment here describing the # of bits?#5604

Suggested change
ROTP::Base32.random(20)
ROTP::Base32.random(20) # 160-bit secret, per RFC 4226

end

def authenticate_direct_otp(code)
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 @@ -287,7 +287,7 @@
it 'generates a secret 16 characters long' do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this spec title is now wrong

Suggested change
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 16
expect(secret.length).to eq 32
end
end

Expand Down