flash_cookie_session 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.rdoc CHANGED
@@ -76,6 +76,27 @@ I'm not sure who first figured everything out, so I won't bother trying to credi
76
76
 
77
77
  With SWFUpload, the post_params are sent along with the file upload, which would be in params[:Filedata] in this example.
78
78
 
79
+ Let's break this down a little so you understand it better:
80
+
81
+ post_params : {
82
+ "<%= key = Rails.application.config.session_options[:key] %>" : "<%= cookies[key] %>",
83
+ "<%= request_forgery_protection_token %>" : "<%= form_authenticity_token %>",
84
+ },
85
+
86
+ The first key is your cookie session key which is passed along with every request when the user changes pages. If the server does not know about this session key then it cannot authenticate the user properly and therefore thinks you are not logged in. Since Flash has it's own set of cookies separate from the browser and effectively acts as it's own web browser when making requests to your app, we need to explicitly pass along the web browsersession key along with the Flash request so that the Rails server has all the info it needs to authenticate the user.
87
+
88
+ The second key is the standard authentication token that is passed along to prevent cross-site request forgeries.
89
+
90
+ === Optional Parameters
91
+
92
+ - If you are using a "remember" cookie to keep a user logged in any time they come back to your website, you can pass this in through the params. If this does not get passed in, the server will not be able to authenticate the user properly and you will be scratching your head again wondering what went wrong:
93
+
94
+ "remember_token" : "<%= cookies[:remember_token] %>"
95
+
96
+ The key has to be named `remember_token` but your cookie may be named something other than `:remember_token` so change that accordingly based on your implementation.
97
+
98
+ - If you are getting a "406 Not Acceptable" error on trying to upload, you might need to setup an extra set of params. Try adding '+_http_accept+': '+text+/+html+' (or any other appropriate media type that your respond_to block in your controller action needs - 'text/javascript' for format.js, etc) to post_params above.
99
+
79
100
  === Additional info
80
101
 
81
102
  This is frustrating and annoying stuff, and I'm sorry that we have to deal with it. If you have an idea about how to improve the situation or example for additional Flash uploaders, pull requests that expand on the README and/or Rails 3 gem are more than welcome.
@@ -1,6 +1,6 @@
1
1
  module FlashCookieSession
2
2
  class Middleware
3
- def initialize(app, session_key = '_session_id')
3
+ def initialize(app, session_key = Rails.application.config.session_options[:key])
4
4
  @app = app
5
5
  @session_key = session_key
6
6
  end
@@ -8,10 +8,13 @@ module FlashCookieSession
8
8
  def call(env)
9
9
  if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
10
10
  req = Rack::Request.new(env)
11
- env['HTTP_COOKIE'] = [ @session_key, req.params[@session_key] ].join('=').freeze if req.params[@session_key]
11
+ the_session_key = [ @session_key, req.params[@session_key] ].join('=').freeze if req.params[@session_key]
12
+ the_remember_token = [ 'remember_token', req.params['remember_token'] ].join('=').freeze if req.params['remember_token']
13
+ cookie_with_remember_token_and_session_key = [ the_remember_token, the_session_key ].join(';').freeze
14
+ env['HTTP_COOKIE'] = cookie_with_remember_token_and_session_key
12
15
  env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".freeze if req.params['_http_accept']
13
16
  end
14
-
17
+
15
18
  @app.call(env)
16
19
  end
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module FlashCookieSession
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_cookie_session
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Trevor Turk
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-01 00:00:00 +00:00
18
+ date: 2011-05-25 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements: []
83
83
 
84
84
  rubyforge_project: flash_cookie_session
85
- rubygems_version: 1.3.7
85
+ rubygems_version: 1.4.2
86
86
  signing_key:
87
87
  specification_version: 3
88
88
  summary: Rails 3 cookie sessions can cooperate with Flash