enforce_same_origin 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4230cec41ec95bb8df4b3048b2da4d2a4573c52
|
4
|
+
data.tar.gz: b447457e7275e38404093edfa029700ddbb1bdda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6377ceddde22d4c613929d42f02ab81d985287291e8f100944cb7152b9fb75263a0a4f63ee8511f6be52336f01ef78c35ecaf5e2178710153d7548a716734e7
|
7
|
+
data.tar.gz: 6a07b7dc5fa288185392ea005def4c91f51f19f0fcdb564ed16302b326892bb4036e1a6580cb3a48f3a5b234d6defaa22d727c06a14ec52e5f2170a3a7ee9d11
|
@@ -8,8 +8,11 @@ module Rack
|
|
8
8
|
def call(env)
|
9
9
|
response = @app.call(env)
|
10
10
|
headers = Rack::Utils::HeaderHash.new(response[1])
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
unless headers['X-Frame-Options'] == 'SAMEORIGIN'
|
13
|
+
headers['X-Frame-Options'] = 'SAMEORIGIN'
|
14
|
+
response[1] = headers
|
15
|
+
end
|
13
16
|
|
14
17
|
response
|
15
18
|
end
|
@@ -6,7 +6,15 @@ describe Rack::EnforceSameOrigin do
|
|
6
6
|
let(:response) { request.call({ }) }
|
7
7
|
let(:response_headers) { response[1] }
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
it 'sets X-Frame-Options correctly' do
|
10
|
+
expect(response_headers['X-Frame-Options']).to eq 'SAMEORIGIN'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when the header is already set" do
|
14
|
+
let(:app) { Proc.new {[200, { 'X-Frame-Options' => 'SAMEORIGIN' }, [ ]]} }
|
15
|
+
|
16
|
+
it "doesn't duplicate the X-Frame-Options" do
|
17
|
+
expect(response_headers['X-Frame-Options']).to eq 'SAMEORIGIN'
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|