Skip to content

Commit

Permalink
Use app.credentials to get the secret_key_base
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Mar 23, 2018
1 parent 412ecf7 commit c270496
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/controllers/concerns/blacklight/token_based_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ 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')[0..(key_len - 1)]
secret_key_generator.generate_key('encrypted user session key')[0..(key_len - 1)]
end

def secret_key_generator
@secret_key_generator ||= begin
app = Rails.application

secret_key_base = if app.respond_to?(:credentials)
# Rails 5.2+
app.credentials.secret_key_base
else
# Rails <= 5.1
app.secrets.secret_key_base
end
ActiveSupport::KeyGenerator.new(secret_key_base)
end
end

def message_encryptor
Expand Down

0 comments on commit c270496

Please sign in to comment.