Skip to content

Commit

Permalink
hashes device_secret lookup value
Browse files Browse the repository at this point in the history
  • Loading branch information
bramleyjl committed May 14, 2024
1 parent e438443 commit 7439515
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/services/sign_in/session_revoker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def delete_session!
end

def delete_device_sessions
sessions = OAuthSession.where(hashed_device_secret: device_secret)
hashed_device_secret = get_hash(device_secret)
sessions = OAuthSession.where(hashed_device_secret:)
return if sessions.empty?

sessions.each(&:destroy!)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/sign_in/o_auth_sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
refresh_creation { Time.zone.now }
user_verification { create(:user_verification, user_account:) }
credential_email { Faker::Internet.email }
hashed_device_secret { SecureRandom.hex }
hashed_device_secret { Digest::SHA256.hexdigest(SecureRandom.hex) }

Check failure on line 13 in spec/factories/sign_in/o_auth_sessions.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/ExtraSpacing: Unnecessary spacing detected.
user_attributes do
{ first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
Expand Down
2 changes: 1 addition & 1 deletion spec/services/sign_in/session_revoker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

context 'and other sessions exist with the same device_secret' do
let!(:connected_session) do
create(:oauth_session, hashed_device_secret: device_secret)
create(:oauth_session, hashed_device_secret: Digest::SHA256.hexdigest(device_secret))
end

it 'destroys all other sessions with the same device_secret' do
Expand Down

0 comments on commit 7439515

Please sign in to comment.