review: use salt to generate key

This commit is contained in:
sebastiencarceles 2022-09-13 07:47:30 +02:00
parent f154bb56e6
commit 9aaef79a3d
4 changed files with 4 additions and 4 deletions

View file

@ -41,7 +41,7 @@ module Manager
def decrypted_params
@decrypted_params ||= ActiveSupport::MessageVerifier.new(
Rails.application.key_generator.generate_key(ENV["SECRET_KEY_BASE"])
Rails.application.key_generator.generate_key("confirm_adding_administrateur")
).verify(Base64.urlsafe_decode64(params[:q]))
end

View file

@ -38,7 +38,7 @@ module Manager
end
def encrypt(parameters)
key = Rails.application.key_generator.generate_key(ENV["SECRET_KEY_BASE"])
key = Rails.application.key_generator.generate_key("confirm_adding_administrateur")
verifier = ActiveSupport::MessageVerifier.new(key)
Base64.urlsafe_encode64(verifier.generate(parameters))
end

View file

@ -157,7 +157,7 @@ RSpec.describe Manager::AdministrateurConfirmationsController, type: :controller
private
def encrypt(parameters)
key = Rails.application.key_generator.generate_key(ENV["SECRET_KEY_BASE"])
key = Rails.application.key_generator.generate_key("confirm_adding_administrateur")
verifier = ActiveSupport::MessageVerifier.new(key)
Base64.urlsafe_encode64(verifier.generate(parameters))
end

View file

@ -66,7 +66,7 @@ describe Manager::ConfirmationUrlsController, type: :controller do
private
def encrypt(parameters)
key = Rails.application.key_generator.generate_key(ENV["SECRET_KEY_BASE"])
key = Rails.application.key_generator.generate_key("confirm_adding_administrateur")
verifier = ActiveSupport::MessageVerifier.new(key)
Base64.urlsafe_encode64(verifier.generate(parameters))
end