File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed
Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,16 @@ def content_security_policy_style_nonce(request)
149149 content_security_policy_nonce ( request , CSP ::STYLE_SRC )
150150 end
151151
152+ # Public: Retreives the config for a given header type:
153+ #
154+ # Checks to see if there is an override for this request, then
155+ # Checks to see if a named override is used for this request, then
156+ # Falls back to the global config
157+ def config_for ( request )
158+ request . env [ SECURE_HEADERS_CONFIG ] ||
159+ Configuration . get ( Configuration ::DEFAULT_CONFIG )
160+ end
161+
152162 private
153163
154164 # Private: gets or creates a nonce for CSP.
@@ -217,16 +227,6 @@ def use_cached_headers(default_headers, request)
217227 end
218228 end
219229
220- # Private: Retreives the config for a given header type:
221- #
222- # Checks to see if there is an override for this request, then
223- # Checks to see if a named override is used for this request, then
224- # Falls back to the global config
225- def config_for ( request )
226- request . env [ SECURE_HEADERS_CONFIG ] ||
227- Configuration . get ( Configuration ::DEFAULT_CONFIG )
228- end
229-
230230 # Private: chooses the applicable CSP header for the provided user agent.
231231 #
232232 # headers - a hash of header_config_key => [header_name, header_value]
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ def call(env)
1111 req = Rack ::Request . new ( env )
1212 status , headers , response = @app . call ( env )
1313
14- flag_cookies_as_secure! ( headers ) if config ( req ) . secure_cookies
14+ config = SecureHeaders . config_for ( req )
15+ flag_cookies_as_secure! ( headers ) if config . secure_cookies
1516 headers . merge! ( SecureHeaders . header_hash_for ( req ) )
1617 [ status , headers , response ]
1718 end
@@ -33,9 +34,5 @@ def flag_cookies_as_secure!(headers)
3334 end . join ( "\n " )
3435 end
3536 end
36-
37- def config ( req )
38- req . env [ SECURE_HEADERS_CONFIG ] || Configuration . get ( Configuration ::DEFAULT_CONFIG )
39- end
4037 end
4138end
You can’t perform that action at this time.
0 commit comments