secure_cookies2 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-version +1 -0
- data/.travis.yml +28 -0
- data/Gemfile +23 -0
- data/Guardfile +13 -0
- data/LICENSE +21 -0
- data/README.md +68 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/secure_cookies.rb +111 -0
- data/lib/secure_cookies/cookie.rb +135 -0
- data/lib/secure_cookies/middleware.rb +55 -0
- data/lib/secure_cookies/railtie.rb +13 -0
- data/lib/secure_cookies/version.rb +3 -0
- data/secure_cookies.gemspec +38 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4142848af4035583bb4d06f0dd5cd2c389835536d386c68105a733ed06964b41
|
4
|
+
data.tar.gz: 682e0f46d1dc106765e4c99dd759c67deccd98039822e3e72c8944c6b694bd03
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22134aba7a75ac4f603a7d74355c8b019453608655701988aef7493ae9d03050e797e7e44d392fdf10a8100530fd986ea423f9839f5283652de1247ad755f5c8
|
7
|
+
data.tar.gz: 565616b86b7449080b5a4eb8293a1b27e819ea5c95c998dbd3dc4f2f757b9d5fb73a89dc24ddb3837f5e71a7f26ebcb8f34e74e7f13f9edef74ab4e9cc90790f
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- ruby-head
|
5
|
+
- 2.6.1
|
6
|
+
- 2.5.0
|
7
|
+
- 2.4.3
|
8
|
+
- jruby-head
|
9
|
+
|
10
|
+
env:
|
11
|
+
- SUITE=rspec spec
|
12
|
+
- SUITE=rubocop
|
13
|
+
|
14
|
+
script: bundle exec $SUITE
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: jruby-head
|
19
|
+
- rvm: ruby-head
|
20
|
+
|
21
|
+
before_install:
|
22
|
+
- gem update --system
|
23
|
+
- gem --version
|
24
|
+
- gem update bundler
|
25
|
+
bundler_args: --without guard -j 3
|
26
|
+
|
27
|
+
sudo: false
|
28
|
+
cache: bundler
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
source "https://rubygems.org"
|
3
|
+
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem "coveralls"
|
8
|
+
gem "json"
|
9
|
+
gem "pry-nav"
|
10
|
+
gem "rack"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rubocop"
|
13
|
+
gem "rubocop-github"
|
14
|
+
gem "term-ansicolor"
|
15
|
+
gem "tins"
|
16
|
+
end
|
17
|
+
|
18
|
+
group :guard do
|
19
|
+
gem "growl"
|
20
|
+
gem "guard-rspec"
|
21
|
+
gem "rb-fsevent"
|
22
|
+
gem "terminal-notifier-guard"
|
23
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
guard :rspec, cmd: "bundle exec rspec", all_on_start: true, all_after_pass: true do
|
3
|
+
require "guard/rspec/dsl"
|
4
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
5
|
+
|
6
|
+
# RSpec files
|
7
|
+
rspec = dsl.rspec
|
8
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_files)
|
11
|
+
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Neil Matatall
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# SecureCookies
|
2
|
+
|
3
|
+
SecureCookies is an extract of the cookie functionality from [secure_headers](https://github.com/twitter/secure_headers). Rails has good header support but the cookie support is still lacking. Maybe one day this functionality will be added to rails core.
|
4
|
+
|
5
|
+
## Configuration
|
6
|
+
|
7
|
+
These can be defined in the form of a boolean, or as a Hash for more refined configuration.
|
8
|
+
|
9
|
+
__Note__: Regardless of the configuration specified, Secure cookies are only enabled for HTTPS requests.
|
10
|
+
|
11
|
+
#### Defaults
|
12
|
+
|
13
|
+
By default, all cookies will get both `Secure`, `HttpOnly`, and `SameSite=Lax`.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
config.cookies = {
|
17
|
+
secure: true, # defaults to true but will be a no op on non-HTTPS requests
|
18
|
+
httponly: true, # defaults to true
|
19
|
+
samesite: { # defaults to set `SameSite=Lax`
|
20
|
+
lax: true
|
21
|
+
}
|
22
|
+
}
|
23
|
+
```
|
24
|
+
|
25
|
+
#### Boolean-based configuration
|
26
|
+
|
27
|
+
Boolean-based configuration is intended to globally enable or disable a specific cookie attribute. *Note: As of 4.0, you must use OPT_OUT rather than false to opt out of the defaults.*
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config.cookies = {
|
31
|
+
secure: true, # mark all cookies as Secure
|
32
|
+
httponly: OPT_OUT, # do not mark any cookies as HttpOnly
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Hash-based configuration
|
37
|
+
|
38
|
+
Hash-based configuration allows for fine-grained control.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
config.cookies = {
|
42
|
+
secure: { except: ['_guest'] }, # mark all but the `_guest` cookie as Secure
|
43
|
+
httponly: { only: ['_rails_session'] }, # only mark the `_rails_session` cookie as HttpOnly
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
#### SameSite cookie configuration
|
48
|
+
|
49
|
+
SameSite cookies permit either `Strict` or `Lax` enforcement mode options.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
config.cookies = {
|
53
|
+
samesite: {
|
54
|
+
strict: true # mark all cookies as SameSite=Strict
|
55
|
+
}
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
`Strict` and `Lax` enforcement modes can also be specified using a Hash.
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
config.cookies = {
|
63
|
+
samesite: {
|
64
|
+
strict: { only: ['_rails_session'] },
|
65
|
+
lax: { only: ['_guest'] }
|
66
|
+
}
|
67
|
+
}
|
68
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "secure_cookies"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require "secure_cookies/cookie"
|
2
|
+
require "secure_cookies/middleware"
|
3
|
+
require "secure_cookies/railtie"
|
4
|
+
require "secure_cookies/version"
|
5
|
+
|
6
|
+
module SecureCookies
|
7
|
+
OPT_OUT = Object.new
|
8
|
+
|
9
|
+
DEFAULT_CONFIG = {
|
10
|
+
secure: true, # defaults to true but will be a no op on non-HTTPS requests
|
11
|
+
httponly: true, # defaults to true
|
12
|
+
samesite: { # defaults to set `SameSite=Lax`
|
13
|
+
lax: true
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def config
|
19
|
+
@config || DEFAULT_CONFIG
|
20
|
+
end
|
21
|
+
def config=(configuration)
|
22
|
+
raise RuntimeError, "Already configured" if @config
|
23
|
+
@config = configuration
|
24
|
+
@config.freeze
|
25
|
+
validate!
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate!
|
29
|
+
return if config == OPT_OUT
|
30
|
+
validate_config!
|
31
|
+
validate_secure_config! unless config[:secure].nil?
|
32
|
+
validate_httponly_config! unless config[:httponly].nil?
|
33
|
+
validate_samesite_config! unless config[:samesite].nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def validate_config!
|
39
|
+
raise CookiesConfigError.new("config must be a hash.") unless is_hash?(config)
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate_secure_config!
|
43
|
+
validate_hash_or_true_or_opt_out!(:secure)
|
44
|
+
validate_exclusive_use_of_hash_constraints!(config[:secure], :secure)
|
45
|
+
end
|
46
|
+
|
47
|
+
def validate_httponly_config!
|
48
|
+
validate_hash_or_true_or_opt_out!(:httponly)
|
49
|
+
validate_exclusive_use_of_hash_constraints!(config[:httponly], :httponly)
|
50
|
+
end
|
51
|
+
|
52
|
+
def validate_samesite_config!
|
53
|
+
return if config[:samesite] == OPT_OUT
|
54
|
+
raise CookiesConfigError.new("samesite cookie config must be a hash") unless is_hash?(config[:samesite])
|
55
|
+
|
56
|
+
validate_samesite_boolean_config!
|
57
|
+
validate_samesite_hash_config!
|
58
|
+
end
|
59
|
+
|
60
|
+
# when configuring with booleans, only one enforcement is permitted
|
61
|
+
def validate_samesite_boolean_config!
|
62
|
+
if config[:samesite].key?(:lax) && config[:samesite][:lax].is_a?(TrueClass) && config[:samesite].key?(:strict)
|
63
|
+
raise CookiesConfigError.new("samesite cookie config is invalid, combination use of booleans and Hash to configure lax and strict enforcement is not permitted.")
|
64
|
+
elsif config[:samesite].key?(:strict) && config[:samesite][:strict].is_a?(TrueClass) && config[:samesite].key?(:lax)
|
65
|
+
raise CookiesConfigError.new("samesite cookie config is invalid, combination use of booleans and Hash to configure lax and strict enforcement is not permitted.")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def validate_samesite_hash_config!
|
70
|
+
# validate Hash-based samesite configuration
|
71
|
+
if is_hash?(config[:samesite][:lax])
|
72
|
+
validate_exclusive_use_of_hash_constraints!(config[:samesite][:lax], "samesite lax")
|
73
|
+
|
74
|
+
if is_hash?(config[:samesite][:strict])
|
75
|
+
validate_exclusive_use_of_hash_constraints!(config[:samesite][:strict], "samesite strict")
|
76
|
+
validate_exclusive_use_of_samesite_enforcement!(:only)
|
77
|
+
validate_exclusive_use_of_samesite_enforcement!(:except)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def validate_hash_or_true_or_opt_out!(attribute)
|
83
|
+
if !(is_hash?(config[attribute]) || is_true_or_opt_out?(config[attribute]))
|
84
|
+
raise CookiesConfigError.new("#{attribute} cookie config must be a hash, true, or SecureCookies::OPT_OUT")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# validate exclusive use of only or except but not both at the same time
|
89
|
+
def validate_exclusive_use_of_hash_constraints!(conf, attribute)
|
90
|
+
return unless is_hash?(conf)
|
91
|
+
if conf.key?(:only) && conf.key?(:except)
|
92
|
+
raise CookiesConfigError.new("#{attribute} cookie config is invalid, simultaneous use of conditional arguments `only` and `except` is not permitted.")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# validate exclusivity of only and except members within strict and lax
|
97
|
+
def validate_exclusive_use_of_samesite_enforcement!(attribute)
|
98
|
+
if (intersection = (config[:samesite][:lax].fetch(attribute, []) & config[:samesite][:strict].fetch(attribute, []))).any?
|
99
|
+
raise CookiesConfigError.new("samesite cookie config is invalid, cookie(s) #{intersection.join(', ')} cannot be enforced as lax and strict")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def is_hash?(obj)
|
104
|
+
obj && obj.is_a?(Hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
def is_true_or_opt_out?(obj)
|
108
|
+
obj && (obj.is_a?(TrueClass) || obj == OPT_OUT)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "cgi"
|
3
|
+
|
4
|
+
module SecureCookies
|
5
|
+
class CookiesConfigError < StandardError; end
|
6
|
+
class Cookie
|
7
|
+
attr_reader :raw_cookie, :config
|
8
|
+
|
9
|
+
COOKIE_DEFAULTS = {
|
10
|
+
httponly: true,
|
11
|
+
secure: true,
|
12
|
+
samesite: { lax: true },
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def initialize(cookie, config)
|
16
|
+
@raw_cookie = cookie
|
17
|
+
unless config == OPT_OUT
|
18
|
+
config ||= {}
|
19
|
+
config = COOKIE_DEFAULTS.merge(config)
|
20
|
+
end
|
21
|
+
@config = config
|
22
|
+
@attributes = {
|
23
|
+
httponly: nil,
|
24
|
+
samesite: nil,
|
25
|
+
secure: nil,
|
26
|
+
}
|
27
|
+
|
28
|
+
parse(cookie)
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@raw_cookie.dup.tap do |c|
|
33
|
+
c << "; secure" if secure?
|
34
|
+
c << "; HttpOnly" if httponly?
|
35
|
+
c << "; #{samesite_cookie}" if samesite?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def secure?
|
40
|
+
flag_cookie?(:secure) && !already_flagged?(:secure)
|
41
|
+
end
|
42
|
+
|
43
|
+
def httponly?
|
44
|
+
flag_cookie?(:httponly) && !already_flagged?(:httponly)
|
45
|
+
end
|
46
|
+
|
47
|
+
def samesite?
|
48
|
+
flag_samesite? && !already_flagged?(:samesite)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def parsed_cookie
|
54
|
+
@parsed_cookie ||= CGI::Cookie.parse(raw_cookie)
|
55
|
+
end
|
56
|
+
|
57
|
+
def already_flagged?(attribute)
|
58
|
+
@attributes[attribute]
|
59
|
+
end
|
60
|
+
|
61
|
+
def flag_cookie?(attribute)
|
62
|
+
return false if config == OPT_OUT
|
63
|
+
case config[attribute]
|
64
|
+
when TrueClass
|
65
|
+
true
|
66
|
+
when Hash
|
67
|
+
conditionally_flag?(config[attribute])
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def conditionally_flag?(configuration)
|
74
|
+
if(Array(configuration[:only]).any? && (Array(configuration[:only]) & parsed_cookie.keys).any?)
|
75
|
+
true
|
76
|
+
elsif(Array(configuration[:except]).any? && (Array(configuration[:except]) & parsed_cookie.keys).none?)
|
77
|
+
true
|
78
|
+
else
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def samesite_cookie
|
84
|
+
if flag_samesite_lax?
|
85
|
+
"SameSite=Lax"
|
86
|
+
elsif flag_samesite_strict?
|
87
|
+
"SameSite=Strict"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def flag_samesite?
|
92
|
+
return false if config == OPT_OUT || config[:samesite] == OPT_OUT
|
93
|
+
flag_samesite_lax? || flag_samesite_strict?
|
94
|
+
end
|
95
|
+
|
96
|
+
def flag_samesite_lax?
|
97
|
+
flag_samesite_enforcement?(:lax)
|
98
|
+
end
|
99
|
+
|
100
|
+
def flag_samesite_strict?
|
101
|
+
flag_samesite_enforcement?(:strict)
|
102
|
+
end
|
103
|
+
|
104
|
+
def flag_samesite_enforcement?(mode)
|
105
|
+
return unless config[:samesite]
|
106
|
+
|
107
|
+
if config[:samesite].is_a?(TrueClass) && mode == :lax
|
108
|
+
return true
|
109
|
+
end
|
110
|
+
|
111
|
+
case config[:samesite][mode]
|
112
|
+
when Hash
|
113
|
+
conditionally_flag?(config[:samesite][mode])
|
114
|
+
when TrueClass
|
115
|
+
true
|
116
|
+
else
|
117
|
+
false
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def parse(cookie)
|
122
|
+
return unless cookie
|
123
|
+
|
124
|
+
cookie.split(/[;,]\s?/).each do |pairs|
|
125
|
+
name, values = pairs.split("=", 2)
|
126
|
+
name = CGI.unescape(name)
|
127
|
+
|
128
|
+
attribute = name.downcase.to_sym
|
129
|
+
if @attributes.has_key?(attribute)
|
130
|
+
@attributes[attribute] = values || true
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module SecureCookies
|
3
|
+
class Middleware
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
# merges the hash of headers into the current header set.
|
9
|
+
def call(env)
|
10
|
+
req = Rack::Request.new(env)
|
11
|
+
status, headers, response = @app.call(env)
|
12
|
+
|
13
|
+
unless SecureCookies.config == OPT_OUT
|
14
|
+
flag_cookies!(headers, override_secure(env, SecureCookies.config))
|
15
|
+
end
|
16
|
+
|
17
|
+
[status, headers, response]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# inspired by https://github.com/tobmatth/rack-ssl-enforcer/blob/6c014/lib/rack/ssl-enforcer.rb#L183-L194
|
23
|
+
def flag_cookies!(headers, config)
|
24
|
+
if cookies = headers["Set-Cookie"]
|
25
|
+
# Support Rails 2.3 / Rack 1.1 arrays as headers
|
26
|
+
cookies = cookies.split("\n") unless cookies.is_a?(Array)
|
27
|
+
|
28
|
+
headers["Set-Cookie"] = cookies.map do |cookie|
|
29
|
+
SecureCookies::Cookie.new(cookie, config).to_s
|
30
|
+
end.join("\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# disable Secure cookies for non-https requests
|
35
|
+
def override_secure(env, config = {})
|
36
|
+
if scheme(env) != "https" && config != OPT_OUT
|
37
|
+
config = config.dup
|
38
|
+
config[:secure] = OPT_OUT
|
39
|
+
end
|
40
|
+
|
41
|
+
config
|
42
|
+
end
|
43
|
+
|
44
|
+
# derived from https://github.com/tobmatth/rack-ssl-enforcer/blob/6c014/lib/rack/ssl-enforcer.rb#L119
|
45
|
+
def scheme(env)
|
46
|
+
if env["HTTPS"] == "on" || env["HTTP_X_SSL_REQUEST"] == "on"
|
47
|
+
"https"
|
48
|
+
elsif env["HTTP_X_FORWARDED_PROTO"]
|
49
|
+
env["HTTP_X_FORWARDED_PROTO"].split(",")[0]
|
50
|
+
else
|
51
|
+
env["rack.url_scheme"]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rails 3.1+
|
3
|
+
if defined?(Rails::Railtie)
|
4
|
+
module SecureCookies
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
isolate_namespace SecureCookies if defined? isolate_namespace # rails 3.0
|
7
|
+
|
8
|
+
initializer "secure_cookies.middleware" do
|
9
|
+
Rails.application.config.middleware.insert_before 0, SecureCookies::Middleware
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "secure_cookies/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "secure_cookies2"
|
8
|
+
spec.version = SecureCookies::VERSION
|
9
|
+
spec.authors = ["Neil Matatall"]
|
10
|
+
spec.email = ["oreoshake@users.noreply.github.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Automatically marks all cookies as secure, httponly, and samesite=lax}
|
13
|
+
spec.description = %q{Secure your cookies with an API for opting out}
|
14
|
+
spec.homepage = "https://github.com/oreoshake/secure_cookies"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/oreoshake/secure_cookies"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/oreoshake/secure_cookies/CHANGELOG"
|
22
|
+
else
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
"public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: secure_cookies2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Neil Matatall
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-23 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Secure your cookies with an API for opting out
|
42
|
+
email:
|
43
|
+
- oreoshake@users.noreply.github.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".ruby-version"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- Guardfile
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- lib/secure_cookies.rb
|
59
|
+
- lib/secure_cookies/cookie.rb
|
60
|
+
- lib/secure_cookies/middleware.rb
|
61
|
+
- lib/secure_cookies/railtie.rb
|
62
|
+
- lib/secure_cookies/version.rb
|
63
|
+
- secure_cookies.gemspec
|
64
|
+
homepage: https://github.com/oreoshake/secure_cookies
|
65
|
+
licenses: []
|
66
|
+
metadata:
|
67
|
+
homepage_uri: https://github.com/oreoshake/secure_cookies
|
68
|
+
source_code_uri: https://github.com/oreoshake/secure_cookies
|
69
|
+
changelog_uri: https://github.com/oreoshake/secure_cookies/CHANGELOG
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.0.1
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Automatically marks all cookies as secure, httponly, and samesite=lax
|
89
|
+
test_files: []
|