Skip to content

Commit

Permalink
Deprecate require_ssl config
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed May 21, 2020
1 parent 3e53d2f commit 7e25f23
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
6 changes: 0 additions & 6 deletions config/alchemy/config.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/alchemy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def show
def deprecated_configs
{
url_nesting: true,
require_ssl: nil,
}
end

Expand Down
4 changes: 3 additions & 1 deletion lib/alchemy/ssl_protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 3 additions & 8 deletions spec/libraries/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7e25f23

Please sign in to comment.