You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you need to override your content security policy for a given endpoint. Rather than applying the exception globally, you have a few options:
96
+
97
+
1. Use procs as config values as mentioned above.
98
+
1. Specifying `ensure_security_headers csp: ::SecureHeaders::Configuration.csp.merge(script_src: shadyhost.com)` in a descendent controller will override the settings for that controller only.
99
+
1. Override the `secure_header_options_for` class instance method. e.g.
100
+
101
+
```ruby
102
+
classSomethingController < ApplicationController
103
+
defwumbus
104
+
# gets style-src override
105
+
end
106
+
107
+
defdiffendoofer
108
+
# does not get style-src override
109
+
end
110
+
111
+
defsecure_header_options_for(header, options)
112
+
options =super
113
+
if params[:action] =="wumbus"
114
+
if header ==:csp
115
+
options.merge(style_src:"'self'")
116
+
end
117
+
else
118
+
options
119
+
end
120
+
end
121
+
end
122
+
```
123
+
91
124
## Options for ensure\_security\_headers
92
125
93
126
**To disable any of these headers, supply a value of false (e.g. :hsts => false), supplying nil will set the default value**
0 commit comments