Skip to content

Commit

Permalink
Trim TokenBasedUser#export_secret_token for compatibility with ruby 2…
Browse files Browse the repository at this point in the history
….4.0
  • Loading branch information
cbeer committed Dec 27, 2016
1 parent d9dbbe2 commit 0e7ef7f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/controllers/concerns/blacklight/token_based_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,21 @@ def encrypt_user_id(user_id, current_time = nil)
end

def export_secret_token
ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key('encrypted user session key')
ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key('encrypted user session key')[0..key_len]
end

def message_encryptor
ActiveSupport::MessageEncryptor.new(export_secret_token)
end

private

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

0 comments on commit 0e7ef7f

Please sign in to comment.