rack-iframe 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.travis.yml +10 -0
- data/Gemfile +9 -0
- data/Guardfile +10 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +65 -0
- data/Rakefile +9 -0
- data/TODO +24 -0
- data/lib/rack/iframe.rb +71 -0
- data/lib/rack/iframe/version.rb +5 -0
- data/rack-iframe.gemspec +34 -0
- data/spec/rack-iframe_spec.rb +192 -0
- data/spec/spec_helper.rb +104 -0
- metadata +204 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Jonas Grimfelt, Jaakko Suuturla, Merchii. http://merchii.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
h1. RACK-IFRAME "!https://secure.travis-ci.org/merchii/rack-iframe.png!":http://travis-ci.org/merchii/rack-iframe
|
2
|
+
|
3
|
+
_Rack middleware for enabling problematic web browsers (Internet Explorer and Safari) to use same cookies in iframes as in parent windows._
|
4
|
+
|
5
|
+
h2. Background
|
6
|
+
|
7
|
+
Best described via:
|
8
|
+
|
9
|
+
* "http://tempe.st/tag/ruby-on-rails":http://tempe.st/tag/ruby-on-rails
|
10
|
+
* "http://groups.google.com/group/rack-devel/browse_thread/thread/11da5971522b107b":http://groups.google.com/group/rack-devel/browse_thread/thread/11da5971522b107b
|
11
|
+
* "http://grack.com/blog/2010/01/06/3rd-party-cookies-dom-storage-and-privacy":http://grack.com/blog/2010/01/06/3rd-party-cookies-dom-storage-and-privacy
|
12
|
+
* "http://anantgarg.com/2010/02/18/cross-domain-cookies-in-safari":http://anantgarg.com/2010/02/18/cross-domain-cookies-in-safari
|
13
|
+
|
14
|
+
h2. Installation
|
15
|
+
|
16
|
+
Add to your @Gemfile@:
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
gem 'rack-iframe'
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
...and @bundle install@.
|
23
|
+
|
24
|
+
h2. Usage
|
25
|
+
|
26
|
+
*Minimal:*
|
27
|
+
|
28
|
+
<pre>
|
29
|
+
require 'rack/iframe'
|
30
|
+
|
31
|
+
use Rack::Iframe
|
32
|
+
</pre>
|
33
|
+
|
34
|
+
*Custom - P3P header:*
|
35
|
+
|
36
|
+
<pre>
|
37
|
+
require 'rack/iframe'
|
38
|
+
|
39
|
+
use Rack::Iframe, :p3p => %(CP="NOI DSP LAW NID")
|
40
|
+
</pre>
|
41
|
+
|
42
|
+
h2. Test
|
43
|
+
|
44
|
+
<pre>
|
45
|
+
$ bundle exec rake test
|
46
|
+
</pre>
|
47
|
+
|
48
|
+
...or using "Guard":http://github.com/guard/guard:
|
49
|
+
|
50
|
+
<pre>
|
51
|
+
$ bundle exec guard
|
52
|
+
</pre>
|
53
|
+
|
54
|
+
h2. Notes
|
55
|
+
|
56
|
+
This gem was developed for our own requirements at *"Merchii":http://github.com/merchii*, so feel free to send pull-requests with enhancements of any kind (features, bug-fixes, documentation, tests, etc.) to make it better or useful for you as well.
|
57
|
+
|
58
|
+
h2. To-Do
|
59
|
+
|
60
|
+
Still not ready for prime-time. See "TODO":https://github.com/merchii/rack-iframe/blob/master/TODO.
|
61
|
+
|
62
|
+
h2. License
|
63
|
+
|
64
|
+
Released under the MIT license.
|
65
|
+
Copyright (c) "Jonas Grimfelt":http://github.com/grimen, "Jaakko Suutarla":http://github.com/jaakkos, "Merchii":http://github.com/merchii
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
== CURRENT/NEXT
|
3
|
+
|
4
|
+
x [feature/issue]: Fix/Review "Last-Modified" HTTP cache header case - to comply with W3C spec.
|
5
|
+
|
6
|
+
- [feature]: Track if P3P-headers should be sent via cookie. Reason: We can't assume that only bodies that contain <iframe>-elements needs the P3P header (or so I think right now).
|
7
|
+
|
8
|
+
- [feature]: Add option to send 304 headers but delete "Set-Cookie"-header - not allowed by spec, but seems to work in most browsers/servers anyway.
|
9
|
+
|
10
|
+
|
11
|
+
== LOW-PRIO
|
12
|
+
|
13
|
+
- [refactor/enhancement]: Use 'useragent' gem to parse 'USER_AGENT'-header - https://rubygems.org/gems/useragent
|
14
|
+
|
15
|
+
- [refactor/test]: Use proper integration testing, i.e. mocks/env => Sinatra/headers.
|
16
|
+
|
17
|
+
|
18
|
+
== MAYBE
|
19
|
+
|
20
|
+
- [feature]: Optionally silently/evily inject "the cross-domain iframe JavaScript hack" for Safari - or specified user agents - into the body response. >:)
|
21
|
+
|
22
|
+
- [feature]: Support for policy reference file. http://www.w3.org/TR/P3P/#ref_file
|
23
|
+
|
24
|
+
- [feature]: Support for specifying compact policies by configuration. http://www.w3.org/TR/P3P/#compact_policies http://www.p3pwriter.com/LRN_111.asp
|
data/lib/rack/iframe.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'rack/iframe/version'
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
module Rack
|
6
|
+
class Iframe
|
7
|
+
|
8
|
+
DEFAULT_P3P = %(CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV").freeze
|
9
|
+
|
10
|
+
def initialize(app, options = {})
|
11
|
+
@app, @options = app, options
|
12
|
+
@options[:p3p] ||= DEFAULT_P3P
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
# 1) If P3P: Set a random Etag (If-None-Match) to trick backend to not send cached response (304).
|
17
|
+
set_invalid_etag!(env) if set_p3p_header?(env)
|
18
|
+
|
19
|
+
# 2) Request
|
20
|
+
@status, @headers, @body = @app.call(env)
|
21
|
+
|
22
|
+
# 3) If P3P: Attach P3P header.
|
23
|
+
set_p3p_header! if set_p3p_header?(env)
|
24
|
+
|
25
|
+
# 4) Response
|
26
|
+
[@status, @headers, @body]
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def user_agent(env)
|
32
|
+
env['HTTP_USER_AGENT']
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_invalid_etag!(env)
|
36
|
+
env['HTTP_IF_NONE_MATCH'] = Digest::MD5.hexdigest(Time.now.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_p3p_header!
|
40
|
+
@headers['P3P'] = @options[:p3p]
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_p3p_header?(env)
|
44
|
+
user_agents?([:ie, :safari], env)
|
45
|
+
end
|
46
|
+
|
47
|
+
def user_agent?(id, env)
|
48
|
+
case id
|
49
|
+
when :ie
|
50
|
+
user_agent(env).include?('MSIE')
|
51
|
+
when :safari
|
52
|
+
user_agent(env).include?('Safari')
|
53
|
+
when :opera
|
54
|
+
user_agent(env).include?('Chrome')
|
55
|
+
when :opera
|
56
|
+
user_agent(env).include?('Opera')
|
57
|
+
when :firefox
|
58
|
+
user_agent(env).include?('Firefox')
|
59
|
+
else
|
60
|
+
raise "Define missing browser agent: #{id.inspect}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def user_agents?(ids, env)
|
65
|
+
[*ids].any? do |id|
|
66
|
+
user_agent?(id, env)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
data/rack-iframe.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rack/iframe/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rack-iframe"
|
7
|
+
s.version = Rack::Iframe::VERSION
|
8
|
+
s.authors = ["Merchii", "Jonas Grimfelt", "Jaakko Suuturla"]
|
9
|
+
s.email = ["operations@merchii.com", "grimen@gmail.com", "jaakko@suutarla.com"]
|
10
|
+
s.homepage = "http://github.com/merchii/rack-iframe"
|
11
|
+
s.summary = %q{Rack middleware for enabling problematic web browsers (Internet Explorer and Safari) to use same cookies in iframes as in parent windows.}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = s.name
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'rack'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rake'
|
24
|
+
s.add_development_dependency 'bundler'
|
25
|
+
s.add_development_dependency 'minitest'
|
26
|
+
s.add_development_dependency 'guard'
|
27
|
+
s.add_development_dependency 'guard-bundler'
|
28
|
+
s.add_development_dependency 'guard-minitest'
|
29
|
+
s.add_development_dependency 'rack-test'
|
30
|
+
s.add_development_dependency 'rack-cache'
|
31
|
+
s.add_development_dependency 'chronic'
|
32
|
+
s.add_development_dependency 'awesome_print'
|
33
|
+
s.add_development_dependency 'sinatra'
|
34
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# == References:
|
4
|
+
# - http://tempe.st/tag/ruby-on-rails
|
5
|
+
# - http://groups.google.com/group/rack-devel/browse_thread/thread/11da5971522b107b
|
6
|
+
# - http://grack.com/blog/2010/01/06/3rd-party-cookies-dom-storage-and-privacy
|
7
|
+
# - http://anantgarg.com/2010/02/18/cross-domain-cookies-in-safari
|
8
|
+
|
9
|
+
describe Rack::Iframe do
|
10
|
+
|
11
|
+
describe "VERSION" do
|
12
|
+
it 'should be defined' do
|
13
|
+
defined?(::Rack::Iframe::VERSION)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be a valid version string (e.g. "0.0.1", or "0.0.1.rc1")' do
|
17
|
+
valid_version_string = /^\d+\.\d+\.\d+/
|
18
|
+
Rack::Iframe::VERSION.must_match valid_version_string
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Middleware" do
|
23
|
+
before do
|
24
|
+
@app = CachedApp.new
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "without Rack::Iframe" do
|
28
|
+
before do
|
29
|
+
@user_agents = all_user_agents
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not have P3P headers' do
|
33
|
+
@user_agents.each do |user_agent|
|
34
|
+
request = mock_request(user_agent)
|
35
|
+
|
36
|
+
response = @app.call(request)
|
37
|
+
status, headers, body = response
|
38
|
+
|
39
|
+
headers.key?('P3P').must_equal false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "with Rack::Iframe" do
|
45
|
+
describe "browsers that require the P3P header: IE, Safari" do
|
46
|
+
before do
|
47
|
+
@user_agents = [:ie, :safari]
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "without any HTTP-cache headers" do
|
51
|
+
it 'should send P3P header - modified (200 OK)' do
|
52
|
+
@user_agents.each do |user_agent|
|
53
|
+
request = mock_request(user_agent)
|
54
|
+
|
55
|
+
response = Rack::Iframe.new(@app).call(request)
|
56
|
+
status, headers, body = response
|
57
|
+
|
58
|
+
headers['P3P'].must_equal %(CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV")
|
59
|
+
status.must_equal 200 # modified
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# NOTE: P3P headers with HTTP-cache headers don't work well.
|
65
|
+
|
66
|
+
describe "with HTTP-cache headers" do
|
67
|
+
describe "If-None-Match (Etag)" do
|
68
|
+
it 'should send P3P header - modified (200 OK)' do
|
69
|
+
@user_agents.each do |user_agent|
|
70
|
+
@app = mock_app('Etag' => '123')
|
71
|
+
|
72
|
+
request = mock_request(user_agent, 'HTTP_IF_NONE_MATCH' => '123')
|
73
|
+
|
74
|
+
response = Rack::Iframe.new(@app).call(request)
|
75
|
+
status, headers, body = response
|
76
|
+
|
77
|
+
headers['P3P'].must_equal %(CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV")
|
78
|
+
status.must_equal 200 # modified
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "Last-Modified" do
|
84
|
+
it 'should send P3P header - modified (200 OK)' do
|
85
|
+
skip
|
86
|
+
# @user_agents.each do |user_agent|
|
87
|
+
# @app = mock_app('Last-Modified' => Chronic.parse('0 minutes ago').rfc2822)
|
88
|
+
|
89
|
+
# request = mock_request(user_agent, 'HTTP_IF_MODIFIED_SINCE' => Chronic.parse('1 minute ago').rfc2822)
|
90
|
+
|
91
|
+
# response = Rack::Iframe.new(@app).call(request)
|
92
|
+
# status, headers, body = response
|
93
|
+
|
94
|
+
# headers['P3P'].must_equal %(CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV")
|
95
|
+
# status.must_equal 200 # modified
|
96
|
+
# end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "custom middleware-arguments" do
|
102
|
+
it 'should use custom P3P header if specified via options as :p3p' do
|
103
|
+
request = mock_request(:ie)
|
104
|
+
|
105
|
+
response = Rack::Iframe.new(@app, :p3p => %(CP="NOI DSP LAW NID")).call(request)
|
106
|
+
status, headers, body = response
|
107
|
+
|
108
|
+
headers['P3P'].must_equal %(CP="NOI DSP LAW NID")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "browsers that don't require the P3P header: Chrome, Firefox, Opera" do
|
114
|
+
before do
|
115
|
+
@user_agents = all_user_agents - [:ie, :safari]
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "without any HTTP-cache headers" do
|
119
|
+
it 'should not send P3P header - modified (200 OK)' do
|
120
|
+
@user_agents.each do |user_agent|
|
121
|
+
@app = mock_app()
|
122
|
+
|
123
|
+
request = mock_request(user_agent)
|
124
|
+
|
125
|
+
response = Rack::Iframe.new(@app).call(request)
|
126
|
+
status, headers, body = response
|
127
|
+
|
128
|
+
headers.key?('P3P').must_equal false
|
129
|
+
status.must_equal 200 # modified
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "with HTTP-cache headers" do
|
135
|
+
describe "If-None-Match (Etag)" do
|
136
|
+
it 'should not send P3P header - not modified (304 Not Modified)' do
|
137
|
+
@user_agents.each do |user_agent|
|
138
|
+
@app = mock_app('Etag' => '123')
|
139
|
+
|
140
|
+
request = mock_request(user_agent, 'HTTP_IF_NONE_MATCH' => '123')
|
141
|
+
|
142
|
+
response = Rack::Iframe.new(@app).call(request)
|
143
|
+
status, headers, body = response
|
144
|
+
|
145
|
+
headers.key?('P3P').must_equal false
|
146
|
+
status.must_equal 304 # not modified
|
147
|
+
|
148
|
+
# browser = Rack::Test::Session.new(Rack::MockSession.new(CachedApp))
|
149
|
+
# browser.get '/', {}, 'HTTP_IF_NONE_MATCH' => '123'
|
150
|
+
|
151
|
+
# browser.last_response.headers.key?('P3P').must_equal false
|
152
|
+
# browser.last_response.status.must_equal 304
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "Last-Modified" do
|
158
|
+
it 'should not send P3P header - not modified (304 Not Modified)' do
|
159
|
+
skip
|
160
|
+
# @user_agents.each do |user_agent|
|
161
|
+
# @app = mock_app('Last-Modified' => Chronic.parse('1 minute ago').rfc2822)
|
162
|
+
|
163
|
+
# request = mock_request(user_agent, 'HTTP_IF_MODIFIED_SINCE' => Chronic.parse('0 minutes ago').rfc2822)
|
164
|
+
|
165
|
+
# response = Rack::Iframe.new(@app).call(request)
|
166
|
+
# status, headers, body = response
|
167
|
+
|
168
|
+
# ap headers
|
169
|
+
# headers.key?('P3P').must_equal false
|
170
|
+
# status.must_equal 304 # not modified
|
171
|
+
|
172
|
+
# # response = Rack::Iframe.new(@app).call(request)
|
173
|
+
# # status, headers, body = response
|
174
|
+
|
175
|
+
# # ap headers
|
176
|
+
# # headers.key?('P3P').must_equal false
|
177
|
+
# # status.must_equal 304 # not modified
|
178
|
+
|
179
|
+
# # browser = Rack::Test::Session.new(Rack::MockSession.new(CachedApp))
|
180
|
+
# # browser.get '/', {}, 'HTTP_IF_MODIFIED_SINCE' => Chronic.parse('1 minute ago')
|
181
|
+
|
182
|
+
# # browser.last_response.headers.key?('P3P').must_equal false
|
183
|
+
# # browser.last_response.status.must_equal 200
|
184
|
+
# end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/unit'
|
4
|
+
require 'minitest/spec'
|
5
|
+
require 'minitest/pride'
|
6
|
+
|
7
|
+
require 'rack/test'
|
8
|
+
require 'rack/mock'
|
9
|
+
|
10
|
+
require 'sinatra'
|
11
|
+
require 'rack/cache'
|
12
|
+
require 'chronic'
|
13
|
+
require 'awesome_print'
|
14
|
+
require 'digest/md5'
|
15
|
+
require 'time'
|
16
|
+
|
17
|
+
require 'rack/iframe'
|
18
|
+
|
19
|
+
ENV['RACK_ENV'] = 'test'
|
20
|
+
|
21
|
+
class CachedApp < Sinatra::Base
|
22
|
+
|
23
|
+
use Rack::Cache, :verbose => true, :meta_store => 'heap:/', :entitystore => 'heap:/'
|
24
|
+
|
25
|
+
get '/' do
|
26
|
+
headers['Content-Type'] = 'text/plain'
|
27
|
+
""
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/etag' do
|
31
|
+
headers['Etag'] = '123'
|
32
|
+
headers['Content-Type'] = 'text/plain'
|
33
|
+
""
|
34
|
+
end
|
35
|
+
|
36
|
+
get '/last_modified' do
|
37
|
+
headers['Last-Modified'] = Chronic.parse('0 minutes ago')
|
38
|
+
headers['Content-Type'] = 'text/plain'
|
39
|
+
""
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def mock_app(headers = {}, env = {})
|
44
|
+
default_headers = headers.merge({
|
45
|
+
'Content-Type' => 'text/plain'
|
46
|
+
})
|
47
|
+
body = block_given? ? [yield] : ['']
|
48
|
+
app = proc { [200, default_headers.merge(headers), body] }
|
49
|
+
rack_cache(app)
|
50
|
+
end
|
51
|
+
|
52
|
+
def rack_cache(app, options = {})
|
53
|
+
options = {:verbose => true, :meta_store => 'heap:/', :entitystore => 'heap:/'}.merge(options)
|
54
|
+
Rack::Cache.new(app, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def mock_request(user_agent_key, env = {})
|
58
|
+
headers = {
|
59
|
+
'HTTP_USER_AGENT' => user_agent_string(user_agent_key)
|
60
|
+
}.merge(env)
|
61
|
+
Rack::MockRequest.env_for('/', headers)
|
62
|
+
end
|
63
|
+
|
64
|
+
def random_etag
|
65
|
+
Digest::MD5.hexdigest(Time.now.to_s)
|
66
|
+
end
|
67
|
+
|
68
|
+
def random_date
|
69
|
+
Time.now.rfc2822
|
70
|
+
end
|
71
|
+
|
72
|
+
# TODO: Use "more real" HTTP_USER_AGENT values.
|
73
|
+
def user_agent_string(id)
|
74
|
+
case id
|
75
|
+
when :ie
|
76
|
+
'MSIE'
|
77
|
+
when :safari
|
78
|
+
'Safari'
|
79
|
+
when :chrome
|
80
|
+
'Chrome'
|
81
|
+
when :opera
|
82
|
+
'Opera'
|
83
|
+
when :firefox
|
84
|
+
'Firefox'
|
85
|
+
else
|
86
|
+
raise "Define mising browser agent: #{id.inspect}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def all_user_agents
|
91
|
+
[:ie, :safari, :chrome, :firefox, :opera]
|
92
|
+
end
|
93
|
+
|
94
|
+
# REVIEW: Use or nuke?
|
95
|
+
def set_env!(request, env_key, value)
|
96
|
+
if block_given?
|
97
|
+
old_value = request.env[env_key]
|
98
|
+
request.env[env_key] = value
|
99
|
+
yield
|
100
|
+
request.env[env_key] = old_value
|
101
|
+
else
|
102
|
+
request.env[env_key] = value
|
103
|
+
end
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-iframe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Merchii
|
9
|
+
- Jonas Grimfelt
|
10
|
+
- Jaakko Suuturla
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2011-10-28 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rack
|
18
|
+
requirement: &70167973270460 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *70167973270460
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: &70167973269900 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *70167973269900
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: bundler
|
40
|
+
requirement: &70167973269260 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *70167973269260
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: minitest
|
51
|
+
requirement: &70167973268820 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *70167973268820
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: guard
|
62
|
+
requirement: &70167973268400 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *70167973268400
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: guard-bundler
|
73
|
+
requirement: &70167973267980 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *70167973267980
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: guard-minitest
|
84
|
+
requirement: &70167973267480 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *70167973267480
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rack-test
|
95
|
+
requirement: &70167973266940 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
type: :development
|
102
|
+
prerelease: false
|
103
|
+
version_requirements: *70167973266940
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rack-cache
|
106
|
+
requirement: &70167973266320 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *70167973266320
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: chronic
|
117
|
+
requirement: &70167973265500 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *70167973265500
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: awesome_print
|
128
|
+
requirement: &70167973264440 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: *70167973264440
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: sinatra
|
139
|
+
requirement: &70167973263660 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *70167973263660
|
148
|
+
description: Rack middleware for enabling problematic web browsers (Internet Explorer
|
149
|
+
and Safari) to use same cookies in iframes as in parent windows.
|
150
|
+
email:
|
151
|
+
- operations@merchii.com
|
152
|
+
- grimen@gmail.com
|
153
|
+
- jaakko@suutarla.com
|
154
|
+
executables: []
|
155
|
+
extensions: []
|
156
|
+
extra_rdoc_files: []
|
157
|
+
files:
|
158
|
+
- .gitignore
|
159
|
+
- .travis.yml
|
160
|
+
- Gemfile
|
161
|
+
- Guardfile
|
162
|
+
- MIT-LICENSE
|
163
|
+
- README.textile
|
164
|
+
- Rakefile
|
165
|
+
- TODO
|
166
|
+
- lib/rack/iframe.rb
|
167
|
+
- lib/rack/iframe/version.rb
|
168
|
+
- rack-iframe.gemspec
|
169
|
+
- spec/rack-iframe_spec.rb
|
170
|
+
- spec/spec_helper.rb
|
171
|
+
homepage: http://github.com/merchii/rack-iframe
|
172
|
+
licenses: []
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
segments:
|
184
|
+
- 0
|
185
|
+
hash: 3290203845642389863
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ! '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
hash: 3290203845642389863
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project: rack-iframe
|
197
|
+
rubygems_version: 1.8.10
|
198
|
+
signing_key:
|
199
|
+
specification_version: 3
|
200
|
+
summary: Rack middleware for enabling problematic web browsers (Internet Explorer
|
201
|
+
and Safari) to use same cookies in iframes as in parent windows.
|
202
|
+
test_files:
|
203
|
+
- spec/rack-iframe_spec.rb
|
204
|
+
- spec/spec_helper.rb
|