-
Notifications
You must be signed in to change notification settings - Fork 253
Add Configuration.disable! to completely disable secure_headers #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-7.2
Are you sure you want to change the base?
Changes from all commits
d81007d
0502028
4c0e94a
cbbcaad
b93ac8d
8f188da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ coverage | |
| pkg | ||
| rdoc | ||
| spec/reports | ||
| vendor/bundle | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,33 @@ class AlreadyConfiguredError < StandardError; end | |||||||
| class NotYetConfiguredError < StandardError; end | ||||||||
| class IllegalPolicyModificationError < StandardError; end | ||||||||
| class << self | ||||||||
| # Public: Disable secure_headers entirely. When disabled, no headers will be set. | ||||||||
| # | ||||||||
| # Note: This should be called before Configuration.default. Calling it after | ||||||||
| # Configuration.default has been set will clear the default configuration. | ||||||||
| # | ||||||||
| # Returns nothing | ||||||||
| def disable! | ||||||||
|
||||||||
| def disable! | |
| def disable! | |
| remove_instance_variable(:@default_config) if defined?(@default_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
disable!is called without ever callingdefault, the NOOP_OVERRIDE will not be registered (since the override registration happens in thedefaultmethod at line 39). This means that callingSecureHeaders.opt_out_of_all_protection(request)when the library is disabled will raise anArgumentErrorbecause the NOOP_OVERRIDE doesn't exist.While this may be acceptable behavior (since the library is already disabled), it creates an inconsistent API. Consider either:
disable!as wellopt_out_of_all_protectioncheck if the library is disabled first