DEV: increase the length of backup codes

16 ^ 8 though not tiny but is a workable search space in the event of
breach, 16 ^ 16 is not.
This commit is contained in:
Sam Saffron 2020-01-21 15:32:06 +11:00
parent c677f8ee6a
commit bff9880d63
2 changed files with 3 additions and 2 deletions

View File

@ -191,7 +191,7 @@ module SecondFactorManager
def generate_backup_codes def generate_backup_codes
codes = [] codes = []
10.times do 10.times do
codes << SecureRandom.hex(8) codes << SecureRandom.hex(16)
end end
codes_json = codes.map do |code| codes_json = codes.map do |code|

View File

@ -3548,7 +3548,8 @@ describe UsersController do
response_body = JSON.parse(response.body) response_body = JSON.parse(response.body)
expect(response_body['backup_codes'].length).to be(10) # we use SecureRandom.hex(16) for backup codes, ensure this continues to be the case
expect(response_body['backup_codes'].map(&:length)).to eq([32] * 10)
end end
end end
end end