rack-auth-cookie 0.7.1 → 0.7.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.
- data/lib/rack/auth/cookie.rb +12 -21
- data/rack-auth-cookie.gemspec +1 -1
- data/test/test_rack_auth_cookie.rb +1 -1
- metadata +3 -2
data/lib/rack/auth/cookie.rb
CHANGED
@@ -6,16 +6,24 @@ module Rack
|
|
6
6
|
module Auth
|
7
7
|
class Cookie
|
8
8
|
# The version of the rack-auth-cookie library.
|
9
|
-
VERSION = '0.7.
|
9
|
+
VERSION = '0.7.2'
|
10
10
|
|
11
|
-
# Creates a new Rack::Auth::Cookie object.
|
11
|
+
# Creates a new Rack::Auth::Cookie object.
|
12
|
+
#
|
13
|
+
# The +cookie_name+ param gives the
|
12
14
|
# name of the cookie used to authenticate the requestor. The default is
|
13
15
|
# 'auth_token'.
|
14
16
|
#
|
17
|
+
# The +cookie_domain+ param gives a domain name to use for the cookie.
|
18
|
+
# If unspecified, cookies will be set without specifying a domain.
|
19
|
+
# Per RFC 2965, this should cause user agents to default to the effective
|
20
|
+
# request-host.
|
21
|
+
#
|
15
22
|
def initialize(app, options = {})
|
16
23
|
@app = app
|
17
24
|
@@secret = options[:secret]
|
18
25
|
@@cookie_name = options[:cookie_name] || "auth_token"
|
26
|
+
@@cookie_domain = options[:cookie_domain] || nil
|
19
27
|
@@idle_timeout = options[:idle_timeout] || 3600
|
20
28
|
@@max_lifetime = options[:max_lifetime] || 36000
|
21
29
|
@@env = {}
|
@@ -182,7 +190,7 @@ module Rack
|
|
182
190
|
def self.create_auth_cookie(env)
|
183
191
|
cookie_value = create_auth_token(env)
|
184
192
|
cookie = "#{@@cookie_name}=#{URI.escape(cookie_value)}; "
|
185
|
-
cookie += "domain=.#{
|
193
|
+
cookie += "domain=.#{@@cookie_domain}; " if @@cookie_domain
|
186
194
|
cookie += "path=/; "
|
187
195
|
cookie += "HttpOnly; "
|
188
196
|
end
|
@@ -190,7 +198,7 @@ module Rack
|
|
190
198
|
def self.create_clear_cookie(env)
|
191
199
|
cookie_value = ""
|
192
200
|
cookie = "#{@@cookie_name}=; "
|
193
|
-
cookie += "domain=.#{
|
201
|
+
cookie += "domain=.#{@@cookie_domain}; " if @@cookie_domain
|
194
202
|
cookie += "path=/; "
|
195
203
|
cookie += "expires=Thu, 01-Jan-1970 00:00:00 GMT; "
|
196
204
|
cookie += "HttpOnly; "
|
@@ -199,23 +207,6 @@ module Rack
|
|
199
207
|
def self.generate_hmac(data)
|
200
208
|
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, @@secret, data)
|
201
209
|
end
|
202
|
-
|
203
|
-
def self.raw_host_with_port(env)
|
204
|
-
if forwarded = env["HTTP_X_FORWARDED_HOST"]
|
205
|
-
forwarded.split(/,\s?/).last
|
206
|
-
else
|
207
|
-
env['HTTP_HOST'] || "#{env['SERVER_NAME'] ||
|
208
|
-
env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def self.host(env)
|
213
|
-
raw_host_with_port(env).sub(/:\d+$/, '')
|
214
|
-
end
|
215
|
-
|
216
|
-
def self.top_level_domain(env, tld_length = 1)
|
217
|
-
host(env).split('.').last(1 + tld_length).join('.')
|
218
|
-
end
|
219
210
|
end
|
220
211
|
end
|
221
212
|
end
|
data/rack-auth-cookie.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'rack-auth-cookie'
|
5
|
-
gem.version = '0.7.
|
5
|
+
gem.version = '0.7.2'
|
6
6
|
gem.authors = ["Daniel Berger", "Charlie O'Keefe"]
|
7
7
|
gem.email = 'cokeefe@globe.gov'
|
8
8
|
gem.homepage = 'http://www.github.com/charlieok/rack-auth-cookie'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-auth-cookie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Berger
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-07-28 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- CHANGES
|
38
38
|
- lib/rack/auth/cookie.rb
|
39
39
|
- MANIFEST
|
40
|
+
- rack-auth-cookie-0.7.2.gem
|
40
41
|
- rack-auth-cookie.gemspec
|
41
42
|
- Rakefile
|
42
43
|
- README
|