From 233001749cd00e147f93c17c17e49e5f6094721e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 19 Nov 2013 22:26:52 -0200 Subject: Add application verifier It is an application global verifier that can be used to generate and verify signed messages. See the documentation of ActiveSupport::MessageVerifier for more information. --- railties/lib/rails/application.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index d1e88cfafd..ccd97af655 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -158,6 +158,18 @@ module Rails end end + def verifier + @verifier ||= begin + if config.respond_to?(:message_verifier_salt) + salt = config.message_verifier_salt + end + + salt = salt || 'application verifier' + secret = key_generator.generate_key(salt) + ActiveSupport::MessageVerifier.new(secret) + end + end + # Stores some of the Rails initial environment parameters which # will be used by middlewares and engines to configure themselves. def env_config -- cgit v1.2.3