Skip to content

Commit

Permalink
Merge pull request #3134 from projectblacklight/key_len
Browse files Browse the repository at this point in the history
It's not necessary to trim the output of generate_key
  • Loading branch information
tpendragon authored Feb 15, 2024
2 parents ebdd658 + 73fe6d1 commit 03948a7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions app/controllers/concerns/blacklight/token_based_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def encrypt_user_id(user_id, current_time = nil)
end

def export_secret_token
secret_key_generator.generate_key('encrypted user session key')[0..(key_len - 1)]
secret_key_generator.generate_key('encrypted user session key', key_len)
end

def secret_key_generator
Expand All @@ -58,12 +58,7 @@ def message_encryptor
ActiveSupport::MessageEncryptor.new(export_secret_token)
end

# Ruby 2.4 requires keys of very particular lengths
def key_len
if ActiveSupport::MessageEncryptor.respond_to? :key_len
ActiveSupport::MessageEncryptor.key_len
else
0
end
ActiveSupport::MessageEncryptor.key_len
end
end

0 comments on commit 03948a7

Please sign in to comment.