rack-flash-session 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +39 -0
  2. data/lib/rack/flash-session.rb +21 -0
  3. metadata +69 -0
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ Install
2
+
3
+ $ gem install rack-flash-session
4
+
5
+ Rails
6
+
7
+ # config/environment.rb
8
+ config.gem 'rack-flash-session', :lib => 'rack/flash-session'
9
+ config.middleware.insert_before(ActionController::Base.session_store, 'Rack::FlashSession');
10
+
11
+ Middleware
12
+
13
+ # add a use line to your builder
14
+ require 'rack/flash-session'
15
+ Rack::Builder.new do
16
+ use Rack::FlashSession
17
+ run MyApp.new
18
+ end
19
+
20
+ Options
21
+
22
+ # The default session key is '_session_id' but you can specify your
23
+ # own:
24
+
25
+ use Rack::FlashSession, 'sid'
26
+
27
+ # Or in Rails you can reference the key defined to be used as session key:
28
+
29
+ config.middleware.insert_before(ActionController::Base.session_store, 'Rack::FlashSession', config.action_controller.session[:key])
30
+
31
+ # Note that the session key is used for both the query parameter name
32
+ # and the cookie name.
33
+
34
+ Thanks to:
35
+
36
+ Rob Anderton for posting Flash uploaders, Rails, cookie based
37
+ sessions and CSRF: Rack Middleware to the rescue!
38
+ (http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue)
39
+ on which this gem is based.
@@ -0,0 +1,21 @@
1
+ require 'rack/utils'
2
+
3
+ module Rack
4
+ class FlashSession
5
+
6
+ def initialize(app, session_key = '_session_id')
7
+ @app = app
8
+ @session_key = session_key
9
+ end
10
+
11
+ def call(env)
12
+ debugger
13
+ if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/ then
14
+ params = ::Rack::Request.new(env).params
15
+ env['HTTP_COOKIE'] = [@session_key, params[@session_key]].join('=').freeze unless params[@session_key].nil?
16
+ end
17
+ @app.call(env)
18
+ end
19
+
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-flash-session
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bart Teeuwisse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-20 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.0"
24
+ version:
25
+ description: |+
26
+
27
+ Rack::FlashSession converts a session query parameter to a cookie if the request's user agent is flash.
28
+ http://github.com/bartt/rack-flash-session
29
+
30
+ email: <bart.teeuwisse@thecodemill.biz>
31
+ executables: []
32
+
33
+ extensions: []
34
+
35
+ extra_rdoc_files:
36
+ - README.rdoc
37
+ files:
38
+ - lib/rack/flash-session.rb
39
+ - README.rdoc
40
+ has_rdoc: true
41
+ homepage: http://github.com/bartt/rack-flash-session
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Rack::FlashSession converts a session query parameter to a cookie if the request's user agent is flash
68
+ test_files: []
69
+