rack-strip-cookies 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 089256d61b8c14a2b1615c87644b6f389e0bbbdc
4
+ data.tar.gz: 590ab59a3003724c63d2c01599a9b75e488cb8b6
5
+ SHA512:
6
+ metadata.gz: 98d590df565141ca50a7aa3c7b9c7dc56d2b96c57acb05c4946f37e813e051202a5f9741dda04b9f3d01a0bc32d06653360be89bb66de5f38fae02cbe7ba962f
7
+ data.tar.gz: 54b68cc68e8eaecbf5151b40cc461826fb28da7c06adac34e25d34581247928266cd9411a397702a1b7cb6136aa6f8b3cf10602601cf47b7eeb83da37419777e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ rack-strip-cookies
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.0-preview1
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - ruby-head
7
+ - jruby-19mode
8
+ - rbx-19mode
9
+ notifications:
10
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
7
+ group :test do
8
+ gem 'rack-test'
9
+ gem 'coveralls', require: false
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Claudio Poli
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Rack::StripCookies [![Build Status](https://secure.travis-ci.org/icoretech/rack-strip-cookies.png)](https://travis-ci.org/icoretech/rack-strip-cookies?branch=master) [![Coverage Status](https://coveralls.io/repos/icoretech/rack-strip-cookies/badge.png)](https://coveralls.io/r/icoretech/rack-strip-cookies) [![Dependency Status](https://gemnasium.com/icoretech/rack-strip-cookies.png)](https://gemnasium.com/icoretech/rack-strip-cookies)
2
+
3
+ Simple Rack middleware to remove cookies at specified paths.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rack-strip-cookies'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rack-strip-cookies
18
+
19
+ ## Ruby on Rails
20
+
21
+ This library has been tested on Rails 3.2 and 4.0.
22
+
23
+ To make the middleware available in all environments, open `config/application.rb` and add in `class Application < Rails::Application`:
24
+
25
+ ```ruby
26
+ config.middleware.insert_before(ActionDispatch::Cookies, Rack::StripCookies, paths: %w(/oauth2/token))
27
+ ```
28
+
29
+ If you want to customize the environment in which the middleware is enabled edit the respective environment files instead.
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rake/testtask"
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push "lib"
6
+ t.test_files = FileList['spec/*_spec.rb']
7
+ t.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class StripCookies
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ module Rack
2
+ class StripCookies
3
+ attr_reader :paths
4
+
5
+ def initialize(app, options = {})
6
+ @app, @paths = app, Array(options[:paths])
7
+ end
8
+
9
+ def call(env)
10
+ path = Rack::Request.new(env).path
11
+ status, headers, body = @app.call(env)
12
+
13
+ if paths.include?(path)
14
+ headers.delete('Set-Cookie')
15
+ # request.session_options[:skip] = true
16
+ # env.delete('HTTP_COOKIE')
17
+ end
18
+
19
+ [status, headers, body]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ require 'rack/strip-cookies'
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rack/strip-cookies/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rack-strip-cookies"
8
+ spec.version = Rack::StripCookies::VERSION
9
+ spec.authors = ["Claudio Poli"]
10
+ spec.email = ["claudio@icorete.ch"]
11
+ spec.summary = %q{Rack middleware to remove cookies at user-defined paths.}
12
+ spec.description = %q{Rack middleware to remove cookies at user-defined paths.}
13
+ spec.homepage = "http://github.com/icoretech/rack-strip-cookies"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.0"
22
+ spec.add_development_dependency "rack", "~> 1.2.0"
23
+ spec.add_development_dependency "rack-test", "~> 0.5.4"
24
+ end
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require 'rack/mock'
5
+ require 'rack/test'
6
+ require 'coveralls'
7
+
8
+ require_relative '../lib/rack/strip-cookies'
9
+
10
+ Coveralls.wear!
11
+
12
+ describe Rack::StripCookies do
13
+ include Rack::Test::Methods
14
+
15
+ def app; Rack::Lint.new(@app); end
16
+
17
+ def mock_app(options_or_options_array = {})
18
+ main_app = lambda { |env|
19
+ request = Rack::Request.new(env)
20
+ headers = {'Content-Type' => "text/html"}
21
+ headers['Set-Cookie'] = "id=1; path=/oauth/token; secure; HttpOnly"
22
+ [200, headers, ['Hello there']]
23
+ }
24
+
25
+ builder = Rack::Builder.new
26
+ options_or_options_array = [options_or_options_array] unless options_or_options_array.is_a?(Array)
27
+ Array(options_or_options_array).each do |options|
28
+ builder.use Rack::StripCookies, options
29
+ end
30
+ builder.run main_app
31
+ @app = builder.to_app
32
+ end
33
+
34
+ before do
35
+ mock_app(paths: ["/oauth/token"])
36
+ end
37
+
38
+ it 'does not clean the cookie on another path' do
39
+ get 'http://www.example.org/oauth'
40
+ last_response.headers['Set-Cookie'].split("\n").must_equal(["id=1; path=/oauth/token; secure; HttpOnly"])
41
+ end
42
+
43
+ it 'clean the cookie' do
44
+ get 'http://www.example.org/oauth/token'
45
+ last_response.headers['Set-Cookie'].must_equal(nil)
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-strip-cookies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Claudio Poli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.4
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.4
55
+ description: Rack middleware to remove cookies at user-defined paths.
56
+ email:
57
+ - claudio@icorete.ch
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".ruby-gemset"
65
+ - ".ruby-version"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/rack-strip-cookies.rb
72
+ - lib/rack/strip-cookies.rb
73
+ - lib/rack/strip-cookies/version.rb
74
+ - rack-strip-cookies.gemspec
75
+ - spec/rack-strip-cookies_spec.rb
76
+ homepage: http://github.com/icoretech/rack-strip-cookies
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.1.10
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Rack middleware to remove cookies at user-defined paths.
100
+ test_files:
101
+ - spec/rack-strip-cookies_spec.rb