Skip to content

Commit e46b315

Browse files
committed
add deprecation message around default configuration method
1 parent cfce124 commit e46b315

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/secure_headers.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ class << self
3333
:x_xss_protection, :csp, :x_download_options, :script_hashes,
3434
:x_permitted_cross_domain_policies, :hpkp
3535

36-
def configure &block
36+
# For preparation for the secure_headers 3.x change.
37+
def default &block
3738
instance_eval &block
3839
if File.exists?(SCRIPT_HASH_CONFIG_FILE)
3940
::SecureHeaders::Configuration.script_hashes = YAML.load(File.open(SCRIPT_HASH_CONFIG_FILE))
4041
end
4142
end
43+
44+
def configure &block
45+
warn "[DEPRECATION] `configure` is removed in secure_headers 3.x. Instead use `default`."
46+
default &block
47+
end
4248
end
4349
end
4450

spec/lib/secure_headers_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def stub_user_agent val
2020
end
2121

2222
def reset_config
23-
::SecureHeaders::Configuration.configure do |config|
23+
::SecureHeaders::Configuration.default do |config|
2424
config.hpkp = nil
2525
config.hsts = nil
2626
config.x_frame_options = nil
@@ -139,7 +139,7 @@ def set_security_headers(subject)
139139

140140
context "when disabled by configuration settings" do
141141
it "does not set any headers when disabled" do
142-
::SecureHeaders::Configuration.configure do |config|
142+
::SecureHeaders::Configuration.default do |config|
143143
config.hsts = false
144144
config.hpkp = false
145145
config.x_frame_options = false
@@ -179,7 +179,7 @@ def expect_default_values(hash)
179179
end
180180

181181
it "allows opting out with config" do
182-
::SecureHeaders::Configuration.configure do |config|
182+
::SecureHeaders::Configuration.default do |config|
183183
config.hsts = false
184184
config.csp = false
185185
end
@@ -190,7 +190,7 @@ def expect_default_values(hash)
190190
end
191191

192192
it "produces a hash with a mix of config values, override values, and default values" do
193-
::SecureHeaders::Configuration.configure do |config|
193+
::SecureHeaders::Configuration.default do |config|
194194
config.hsts = { :max_age => '123456'}
195195
config.hpkp = {
196196
:enforce => true,
@@ -205,7 +205,7 @@ def expect_default_values(hash)
205205
end
206206

207207
hash = SecureHeaders::header_hash(:csp => {:default_src => "'none'", :img_src => "data:"})
208-
::SecureHeaders::Configuration.configure do |config|
208+
::SecureHeaders::Configuration.default do |config|
209209
config.hsts = nil
210210
config.hpkp = nil
211211
end

0 commit comments

Comments
 (0)