p3p 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +60 -0
- data/Rakefile +1 -1
- data/lib/p3p.rb +5 -4
- data/lib/p3p/configuration.rb +5 -0
- data/lib/p3p/middleware.rb +4 -3
- data/lib/p3p/railtie.rb +2 -1
- data/lib/p3p/version.rb +2 -1
- data/p3p.gemspec +11 -11
- data/spec/configuration_spec.rb +17 -20
- data/spec/middleware_spec.rb +35 -15
- data/spec/spec_helper.rb +7 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1efe1a6e863dfcfc6f7150b817ac34356565baac
|
4
|
+
data.tar.gz: a3707c343bcb3148b7c1b4f966ee1ec0930678dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72a87707679893d1a54395cdbe7f53c2707e2bdc89d190637da05c3d90c21e046dcde048c18a000a3d66381d28f3eb43fe76814fb4e4a58341901df0ae5b1e3
|
7
|
+
data.tar.gz: 395a8cc7c2ca967b5f639f60e9ff8e3720db698dc43e00144454f9887260f1c1a33c28017be7fe0caee4814f6cf626a26a8c07961009a6ba9c4512e6b889a0de
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
Lint/HandleExceptions:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Metrics/BlockNesting:
|
5
|
+
Max: 2
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
AllowURI: true
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Metrics/MethodLength:
|
12
|
+
CountComments: false
|
13
|
+
Max: 15
|
14
|
+
|
15
|
+
Metrics/ParameterLists:
|
16
|
+
Max: 4
|
17
|
+
CountKeywordArgs: true
|
18
|
+
|
19
|
+
Style/AccessModifierIndentation:
|
20
|
+
EnforcedStyle: outdent
|
21
|
+
|
22
|
+
Style/CollectionMethods:
|
23
|
+
PreferredMethods:
|
24
|
+
map: 'collect'
|
25
|
+
reduce: 'inject'
|
26
|
+
find: 'detect'
|
27
|
+
find_all: 'select'
|
28
|
+
|
29
|
+
Style/Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/DotPosition:
|
33
|
+
EnforcedStyle: trailing
|
34
|
+
|
35
|
+
Style/DoubleNegation:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Style/EachWithObject:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/Encoding:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/HashSyntax:
|
45
|
+
EnforcedStyle: hash_rockets
|
46
|
+
|
47
|
+
Style/Lambda:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/RaiseArgs:
|
51
|
+
EnforcedStyle: compact
|
52
|
+
|
53
|
+
Style/RegexpLiteral:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/SpaceInsideHashLiteralBraces:
|
57
|
+
EnforcedStyle: no_space
|
58
|
+
|
59
|
+
Style/TrailingComma:
|
60
|
+
EnforcedStyleForMultiline: 'comma'
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/p3p.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'p3p/configuration'
|
2
|
+
require 'p3p/middleware'
|
3
|
+
require 'p3p/version'
|
4
|
+
require 'p3p/railtie' if defined?(Rails)
|
5
5
|
|
6
|
+
# Base module
|
6
7
|
module P3P
|
7
8
|
class << self
|
8
9
|
attr_writer :configuration
|
data/lib/p3p/configuration.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module P3P
|
2
|
+
# Responsible for handling P3P configuration
|
2
3
|
class Configuration
|
3
4
|
DEFAULT_HEADER = 'CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'
|
4
5
|
attr_accessor :header
|
5
6
|
|
6
7
|
def initialize
|
8
|
+
set_default_header!
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_default_header!
|
7
12
|
@header = DEFAULT_HEADER
|
8
13
|
end
|
9
14
|
end
|
data/lib/p3p/middleware.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module P3P
|
2
|
+
# Responsible for applying the configured P3P header to the response
|
2
3
|
class Middleware
|
3
|
-
def initialize
|
4
|
+
def initialize(app)
|
4
5
|
@app = app
|
5
6
|
end
|
6
7
|
|
7
|
-
def call
|
8
|
+
def call(env)
|
8
9
|
res = @app.call(env)
|
9
|
-
res[1][
|
10
|
+
res[1]['P3P'] = P3P.configuration.header
|
10
11
|
res
|
11
12
|
end
|
12
13
|
end
|
data/lib/p3p/railtie.rb
CHANGED
data/lib/p3p/version.rb
CHANGED
data/p3p.gemspec
CHANGED
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'p3p/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'p3p'
|
8
8
|
gem.version = P3P::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
gem.homepage =
|
9
|
+
gem.authors = ['Tom Milewski']
|
10
|
+
gem.email = ['tmilewski@gmail.com']
|
11
|
+
gem.description = 'Inserts P3P header'
|
12
|
+
gem.summary = 'Inserts P3P headers to allow cookies to be utilized in iframe scenarios with IE.'
|
13
|
+
gem.homepage = 'https://github.com/tmilewski/p3p'
|
14
14
|
|
15
|
-
gem.files = `git ls-files`.split(
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).collect { |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
18
|
+
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency
|
21
|
-
gem.add_development_dependency
|
20
|
+
gem.add_dependency 'rack'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3.1.0'
|
22
22
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -1,36 +1,33 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
shared_examples
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
app = lambda { |env| [200, headers, []] }
|
9
|
-
request = Rack::MockRequest.env_for('/', lint: true, fatal: true, method: http_verb)
|
3
|
+
shared_examples 'it returns configured P3P header' do |header, http_verb|
|
4
|
+
it "should return custom P3P headers in the case of a #{http_verb} request" do
|
5
|
+
headers = {'Content-Type' => 'text/html'}
|
6
|
+
app = lambda { |_env| [200, headers, []] }
|
7
|
+
request = Rack::MockRequest.env_for('/', :lint => true, :fatal => true, :method => http_verb)
|
10
8
|
response = P3P::Middleware.new(app).call(request)
|
11
9
|
|
12
|
-
expect(response[1]).to include(
|
10
|
+
expect(response[1]).to include('P3P' => header)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
14
|
describe P3P do
|
17
|
-
describe
|
18
|
-
let(:header) {
|
15
|
+
describe '#configure' do
|
16
|
+
let(:header) { 'Fake p3p header' }
|
19
17
|
|
20
18
|
before do
|
21
19
|
P3P.configure do |config|
|
22
|
-
config.header = header
|
20
|
+
config.header = @header
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
|
-
it_should_behave_like
|
27
|
-
it_should_behave_like
|
28
|
-
it_should_behave_like
|
29
|
-
it_should_behave_like
|
30
|
-
it_should_behave_like
|
31
|
-
it_should_behave_like
|
32
|
-
it_should_behave_like
|
33
|
-
it_should_behave_like
|
34
|
-
|
24
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'GET'
|
25
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'POST'
|
26
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'PUT'
|
27
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'DELETE'
|
28
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'HEAD'
|
29
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'OPTIONS'
|
30
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'TRACE'
|
31
|
+
it_should_behave_like 'it returns configured P3P header', @header, 'CONNECT'
|
35
32
|
end
|
36
33
|
end
|
data/spec/middleware_spec.rb
CHANGED
@@ -1,23 +1,43 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
shared_examples
|
4
|
-
it "should return P3P headers in
|
5
|
-
headers = {
|
6
|
-
app = lambda { |
|
7
|
-
request = Rack::MockRequest.env_for('/', lint
|
3
|
+
shared_examples 'it returns P3P headers' do |http_verb|
|
4
|
+
it "should return default P3P headers in the case of a #{http_verb} request" do
|
5
|
+
headers = {'Content-Type' => 'text/html'}
|
6
|
+
app = lambda { |_env| [200, headers, []] }
|
7
|
+
request = Rack::MockRequest.env_for('/', :lint => true, :fatal => true, :method => http_verb)
|
8
8
|
response = P3P::Middleware.new(app).call(request)
|
9
9
|
|
10
|
-
expect(response[1]).to include(
|
10
|
+
expect(response[1]).to include('P3P' => P3P::Configuration::DEFAULT_HEADER)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe P3P::Middleware do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
describe '.initialize' do
|
16
|
+
it 'should set the default header' do
|
17
|
+
expect_any_instance_of(P3P::Configuration).to receive(:set_default_header!)
|
18
|
+
P3P.configure { |_config| }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.set_default_header!' do
|
23
|
+
it 'should set the default header' do
|
24
|
+
header = 'abc123'
|
25
|
+
default_header = P3P::Configuration::DEFAULT_HEADER
|
26
|
+
|
27
|
+
P3P.configure { |c| c.header = header }
|
28
|
+
expect(P3P.configuration.header).to eq header
|
29
|
+
|
30
|
+
P3P.configuration.set_default_header!
|
31
|
+
expect(P3P.configuration.header).to eq default_header
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like 'it returns P3P headers', 'GET'
|
36
|
+
it_should_behave_like 'it returns P3P headers', 'POST'
|
37
|
+
it_should_behave_like 'it returns P3P headers', 'PUT'
|
38
|
+
it_should_behave_like 'it returns P3P headers', 'DELETE'
|
39
|
+
it_should_behave_like 'it returns P3P headers', 'HEAD'
|
40
|
+
it_should_behave_like 'it returns P3P headers', 'OPTIONS'
|
41
|
+
it_should_behave_like 'it returns P3P headers', 'TRACE'
|
42
|
+
it_should_behave_like 'it returns P3P headers', 'CONNECT'
|
23
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'rack'
|
2
|
+
require 'p3p'
|
3
3
|
|
4
4
|
RSpec.configure do |config|
|
5
5
|
config.color = true
|
6
6
|
config.formatter = :documentation
|
7
|
+
config.order = :random
|
8
|
+
|
9
|
+
config.after(:each) do
|
10
|
+
P3P.configuration.set_default_header!
|
11
|
+
end
|
7
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p3p
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Milewski
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|