From 5d7797b104927cd89691c7c10ba40f24a3c32ebf Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 May 2024 09:40:14 -0700 Subject: [PATCH] Improved secret token generation --- CHANGELOG.md | 1 + lib/ahoy_email/engine.rb | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2b03f..d4e3c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.3.0 (unreleased) - Added support for key rotation +- Improved secret token generation ## 2.2.0 (2023-07-02) diff --git a/lib/ahoy_email/engine.rb b/lib/ahoy_email/engine.rb index 7a2ac70..0fc5ef9 100644 --- a/lib/ahoy_email/engine.rb +++ b/lib/ahoy_email/engine.rb @@ -4,12 +4,8 @@ module AhoyEmail class Engine < ::Rails::Engine initializer "ahoy_email" do |app| AhoyEmail.secret_token ||= begin - # Fix for issue with Mailkick and SECRET_KEY_BASE_DUMMY with Rails 7.1 - # https://github.com/ankane/mailkick/pull/74 - if Rails::VERSION::STRING.to_f >= 7.1 && ENV["SECRET_KEY_BASE_DUMMY"] - # TODO use for token in 3.0 - app.key_generator.generate_key("ahoy_email") - end + tokens = [] + tokens << app.key_generator.generate_key("ahoy_email") # TODO remove in 3.0 creds = @@ -23,7 +19,9 @@ class Engine < ::Rails::Engine token = creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token token ||= app.secret_key_base # should come first, but need to maintain backward compatibility - token + tokens << token + + tokens end end end