From b00eefa6e5f7a9c6778107e0497948deb87f196a Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 25 May 2020 14:05:01 +0200 Subject: [PATCH] Deprecate require_ssl config (#1842) --- config/alchemy/config.yml | 6 ------ lib/alchemy/config.rb | 1 + lib/alchemy/ssl_protection.rb | 4 +++- spec/libraries/config_spec.rb | 11 +++-------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/config/alchemy/config.yml b/config/alchemy/config.yml index 4de9c3a600..2f687528a1 100644 --- a/config/alchemy/config.yml +++ b/config/alchemy/config.yml @@ -1,12 +1,6 @@ # == This is the global Alchemy configuration file # -# === Require SSL for login form and all admin modules -# -# NOTE: You have to create a SSL certificate on your server to make this work -# -require_ssl: false - # === Auto Log Out Time # # The amount of time of inactivity in minutes after which the user is kicked out of his current session. diff --git a/lib/alchemy/config.rb b/lib/alchemy/config.rb index e54b421c63..e1c7724d76 100644 --- a/lib/alchemy/config.rb +++ b/lib/alchemy/config.rb @@ -33,6 +33,7 @@ def show def deprecated_configs { url_nesting: true, + require_ssl: nil, } end diff --git a/lib/alchemy/ssl_protection.rb b/lib/alchemy/ssl_protection.rb index aa134e848e..fb32ce7035 100644 --- a/lib/alchemy/ssl_protection.rb +++ b/lib/alchemy/ssl_protection.rb @@ -26,7 +26,9 @@ def ssl_required? # Redirects current request to https. def enforce_ssl - redirect_to url_for(request.params.merge(protocol: 'https')) + redirect_to url_for(request.params.merge(protocol: "https")) end + + deprecate :enforce_ssl, deprecator: Alchemy::Deprecation end end diff --git a/spec/libraries/config_spec.rb b/spec/libraries/config_spec.rb index 9283846e9b..959d69b797 100644 --- a/spec/libraries/config_spec.rb +++ b/spec/libraries/config_spec.rb @@ -17,15 +17,10 @@ module Alchemy context "if config is deprecated" do context "without a new default" do - before do - expect(described_class).to receive(:deprecated_configs).at_least(:once) do - { url_nesting: nil } - end - end - it "warns" do - expect(Alchemy::Deprecation).to receive(:warn) - Config.get(:url_nesting) + expect(Alchemy::Deprecation).to \ + receive(:warn).with("require_ssl configuration is deprecated and will be removed from Alchemy 5.0") + Config.get(:require_ssl) end end