rack-content_security_policy 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -1
- data/README.md +3 -3
- data/lib/rack/content_security_policy.rb +10 -12
- data/lib/rack/content_security_policy/version.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3020478a9da4f0b6203521b966e885cccff4156
|
|
4
|
+
data.tar.gz: f071347ff4e22ad4bb469e79e48579f551ee362b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c7670af664401e3e1f5253810c184c9f67d598fe5843229c1a1ece9eb9805e2a7be8b1bb86b14160b633ebe4f11d7e113f00039b018a2e7e7f370ab942a0263
|
|
7
|
+
data.tar.gz: f730f40ae77ad9ce6aa9623d5f38e39d9885e784aa0e9d9d07f1d1c35c3edc5a043adea4ceb895833b8ce99a9dcf77834008ad05683239d2fc58528460d3a091
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
data/README.md
CHANGED
|
@@ -11,8 +11,8 @@ been used in production. Your feedback is requested.
|
|
|
11
11
|
## About
|
|
12
12
|
|
|
13
13
|
`Rack::ContentSecurityPolicy` is a Rack middleware that makes it easy for your
|
|
14
|
-
Rack based application (Sinatra, Rails) to serve Content
|
|
15
|
-
|
|
14
|
+
Rack based application (Sinatra, Rails) to serve an `Content-Security-Policy` or
|
|
15
|
+
`Content-Security-Policy-Report-Only` header.
|
|
16
16
|
|
|
17
17
|
This middleware was inspired by the [p0deje/content-security-policy](https://github.com/p0deje/content-security-policy)
|
|
18
18
|
middleware and borrows quite a bit of code from that gem. This gem also makes
|
|
@@ -72,7 +72,7 @@ Learn more about the Content Security Policy at the following sites:
|
|
|
72
72
|
require 'rack/content_security_policy'
|
|
73
73
|
|
|
74
74
|
Rack::ContentSecurityPolicy.configure do |d|
|
|
75
|
-
d.report_only =
|
|
75
|
+
d.report_only = false
|
|
76
76
|
d['default-src'] = "'none'"
|
|
77
77
|
d['script-src'] = "'self'"
|
|
78
78
|
d['upgrade-insecure-requests'] = true
|
|
@@ -45,18 +45,16 @@ module Rack
|
|
|
45
45
|
def _call(env)
|
|
46
46
|
status, headers, response = @app.call(env)
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
headers[csp_hdr] = directives
|
|
59
|
-
end
|
|
48
|
+
directives = @directives.sort.map do |d|
|
|
49
|
+
if NO_ARG_DIRECTIVES.include?(d[0])
|
|
50
|
+
d[0]
|
|
51
|
+
else
|
|
52
|
+
"#{d[0]} #{d[1]}"
|
|
53
|
+
end
|
|
54
|
+
end.join('; ')
|
|
55
|
+
|
|
56
|
+
csp_hdr = @report_only ? CSP_REPORT_ONLY_HEADER : CSP_HEADER
|
|
57
|
+
headers[csp_hdr] = directives
|
|
60
58
|
|
|
61
59
|
[status, headers, response]
|
|
62
60
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|