<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Ruby on Rails, JRuby, AWS, EC2, Exalead - Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue! Comments</title>
  <id>tag:thewebfellas.com,2010:/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue/comments</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue/comments.xml" rel="self" type="application/atom+xml"/>
  <link href="/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
  <updated>2010-04-20T21:40:56Z</updated>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Lars Pind</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14807</id>
    <published>2010-04-20T21:40:56Z</published>
    <updated>2010-04-20T21:40:56Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Lars Pind</title>
<content type="html">&lt;p&gt;Here's the initializer that I've used to load the flash cookie middleware in Rails 3 that seems to get the job done:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;MyApp::Application.configure do
  initializer &amp;quot;billing.use_flash_session_cookie_middleware&amp;quot; do |app|
    app.middlewares.use FlashSessionCookieMiddleware, config.session_options[:key]
  end
end&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>toy</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14799</id>
    <published>2010-04-20T09:20:24Z</published>
    <updated>2010-04-20T09:20:24Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by toy</title>
<content type="html">&lt;p&gt;It took me some time to get it work with Rails 2.3.5 and Activerecord-Sessionstore. I put it all into one gist : &lt;a href=&quot;http://gist.github.com/371318&quot;&gt;identify session from Get-vars in Rails 2.3.5 using middleware and Activerecord-Sessionstore&lt;/a&gt; &lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Patrick Berkeley</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14670</id>
    <published>2010-04-14T05:08:49Z</published>
    <updated>2010-04-14T05:08:49Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Patrick Berkeley</title>
<content type="html">&lt;p&gt;Thanks! I ended up setting a constant and using it where needed.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14643</id>
    <published>2010-04-12T21:15:17Z</published>
    <updated>2010-04-12T21:15:17Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;It doesn't look like getting the key has been made easy, unless I've missed something obvious from my quick scan of the code. You could try:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Rails.application.config.session_store.instance_variable_get(:@key)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Another option might be to look at the middleware stack (in config.middleware) and extract the options from the cookie middleware. Neither are particularly nice options though, so it might be best to store the key in a constant somewhere and then just pass it into the cookie options and the middleware options in your initializers.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Patrick Berkeley</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14601</id>
    <published>2010-04-09T19:57:53Z</published>
    <updated>2010-04-09T19:57:53Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Patrick Berkeley</title>
<content type="html">&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;How do you access &lt;code&gt;ActionController::Base.session_options[:key]&lt;/code&gt; in Rails 3? Needed for config/application.rb:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;ActionController::Dispatcher.middleware.insert_before(ActionController::Base.session_store, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key])&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Michael Hasenstein</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14435</id>
    <published>2010-03-31T08:09:39Z</published>
    <updated>2010-03-31T08:09:39Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Michael Hasenstein</title>
<content type="html">&lt;p&gt;I prefer to use mod&lt;em&gt;porter (http://github.com/actionrails/modporter) and let the webserver (Apache) handle the upload. This is especially good if one expects to get a high number of big file uploads, since it would be a huge waste to let relatively giant Rails-processes be occupied with an upload each whie actually not doing anything the whole time but waiting for the upload to complete. mod&lt;/em&gt;porter hands the upload to Rails only when it is FINISHED.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14104</id>
    <published>2010-03-16T18:00:50Z</published>
    <updated>2010-03-16T18:00:50Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;As far as I'm aware &lt;code&gt;RAILS_ROOT&lt;/code&gt; (aka &lt;code&gt;Rails.root&lt;/code&gt;) has always contained the path to the root of your application, the parent directory of 'app' rather than 'app' itself, and looking at the Rails 3 code it looks like this will continue (although the &lt;code&gt;RAILS_ROOT&lt;/code&gt; constant itself has been deprecated). You can verify this by looking in the &lt;kbd&gt;config/boot.rb&lt;/kbd&gt; script for your app where you should see something like:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;RAILS_ROOT = &quot;#{File.dirname(__FILE__)}/..&quot; unless defined?(RAILS_ROOT)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Could it be your own app is picking up a RAILS_ROOT constant defined elsewhere?&lt;/p&gt;

&lt;p&gt;For the content type I've always used &lt;a href=&quot;http://github.com/mattetti/mimetype-fu&quot; title=&quot;Go to GitHub&quot;&gt;mimetype_fu&lt;/a&gt; with a patched &lt;code&gt;Attachment#assign&lt;/code&gt; method. You can achieve something similar with &lt;code&gt;alias_method_chain&lt;/code&gt; although the latest Ruby gods may frown on you for it:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;module Paperclip
  class Attachment 
    def assign_with_mimetype_fu(uploaded_file)
      uploaded_file = uploaded_file.to_file(:original) if uploaded_file.is_a?(Paperclip::Attachment)
      uploaded_file.content_type = File.mime_type?(uploaded_file.original_filename) if uploaded_file.respond_to?(:content_type) &amp;&amp; uploaded_file.content_type.to_s.strip == 'application/octet-stream'
      assign_without_mimetype_fu(uploaded_file)
    end
    alias_method_chain :assign, :mimetype_fu
  end
end&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Evan</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14099</id>
    <published>2010-03-16T15:12:03Z</published>
    <updated>2010-03-16T15:12:03Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Evan</title>
<content type="html">&lt;p&gt;Also, it's worth noting that Flash doesn't preserve the &lt;code&gt;content_type&lt;/code&gt; of the uploaded image, as noted by John Nunemaker in his tutorial &lt;a href=&quot;http://railstips.org/blog/archives/2009/07/21/uploadify-and-rails23/&quot; title=&quot;Uploadify and Rails 2.3&quot;&gt;Uploadify and Rails 2.3&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since I'm using a &lt;a href=&quot;http://github.com/kennon/paperclip&quot; title=&quot;Kennon's Paperclip Fork&quot;&gt;fork of Paperclip by Kennon&lt;/a&gt; which provides supports for automatically computing and storing image dimensions (which is a darn useful thing!), not having the content type at the time of my asset instantiation broke its &quot;auto-dimensioning&quot; capability... or so I think...&lt;/p&gt;

&lt;p&gt;I've managed to work around this by doing this (in my controller):&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@photo = Photo.new(params[:photo])
@photo.image_content_type = MIME::Types.type_for(@photo.image_file_name).to_s
@photo.image_width = Paperclip::Geometry.from_file(params[:photo][:image]).width.to_i
@photo.image_height = Paperclip::Geometry.from_file(params[:photo][:image]).height.to_i
@photo.save!&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If anyone knows of a better way, I'd love to hear about it!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Evan</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:14094</id>
    <published>2010-03-16T13:06:26Z</published>
    <updated>2010-03-16T13:06:26Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Evan</title>
<content type="html">&lt;p&gt;I don't know if this is a change in the more recent versions of Rails or not (I'm currently running 2.3.5), but for those who have read EVERYTHING on this page, copy/pasted the supplied code verbatim, and are still getting this error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;uninitialized constant FlashSessionCookieMiddleware
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Check the load path in &lt;code&gt;environment.rb&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;config.load_paths += %W( #{RAILS_ROOT}/app/middleware )&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;... which SHOULD be...&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;config.load_paths += %W( #{RAILS_ROOT}/middleware )&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;... since &lt;code&gt;RAILS_ROOT&lt;/code&gt; is the &lt;code&gt;app&lt;/code&gt; directory. I definitely spent a good hour banging my head against a wall with this.&lt;/p&gt;

&lt;p&gt;Otherwise, great stuff! Thanks for the excellent write up!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Daniel Brown</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:13051</id>
    <published>2010-02-02T18:04:54Z</published>
    <updated>2010-02-02T18:04:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Daniel Brown</title>
<content type="html">&lt;p&gt;Just in case this helps anyone else, you need to CGI.escape the @session_key parameter being set in the cookie, otherwise it will not work on session keys which have pluses etc in them.&lt;/p&gt;

&lt;p&gt;env['HTTP&lt;em&gt;COOKIE'] = [ @session&lt;/em&gt;key, CGI.escape(params[@session&lt;em&gt;key]) ].join('=').freeze unless params[@session&lt;/em&gt;key].nil?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:12554</id>
    <published>2010-01-13T10:17:44Z</published>
    <updated>2010-01-13T10:17:44Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Seems odd that'd be missing. In case anyone's interested, the &lt;code&gt;u&lt;/code&gt; helper is an alias for &lt;a href=&quot;http://apidock.com/ruby/ERB/Util/url_encode&quot; title=&quot;See the documentation&quot;&gt;&lt;code&gt;url_encode&lt;/code&gt;&lt;/a&gt; in the &lt;code&gt;ERB::Util&lt;/code&gt; module. I wonder if &lt;code&gt;url_encode&lt;/code&gt; is available on jruby...&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>acid</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:12537</id>
    <published>2010-01-13T00:58:14Z</published>
    <updated>2010-01-13T00:58:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by acid</title>
<content type="html">&lt;p&gt;For those of you, who want to use this magic in jruby on rails:&lt;/p&gt;

&lt;p&gt;There is no u helper in jruby on rails, but u can use url_escape, see http://gist.github.com/275807&lt;/p&gt;

&lt;p&gt;acid&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11810</id>
    <published>2009-12-21T08:53:09Z</published>
    <updated>2009-12-21T08:53:09Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;It sounds like you're describing the same session fixation problem as &lt;a href=&quot;#comment-9104&quot; title=&quot;Read Trevor's comment&quot;&gt;Trevor Rowe&lt;/a&gt;: because the Flash gets a 'frozen in time' copy of the session when it is initialised it won't know about changes that might happen to the session from that point on. This would likely explain the errors you get with long running forms too.&lt;/p&gt;

&lt;p&gt;The authenticity token is stored in the session cookie, so if for example you clear your cookies, you're likely to see an invalid authenticity token error on your next request.&lt;/p&gt;

&lt;p&gt;I haven't yet had time to try a fix like Trevor suggests (sending back an updated cookie to JavaScript and dynamically updating the URL used by Flash), but it does sound like a winner. If you're feeling adventurous give it a go and let us know if it works :)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Claudio Poli</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11799</id>
    <published>2009-12-20T19:22:34Z</published>
    <updated>2009-12-20T19:22:34Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Claudio Poli</title>
<content type="html">&lt;p&gt;also, this is what I'm using:
http://pastie.org/750957&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Claudio Poli</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11797</id>
    <published>2009-12-20T19:06:25Z</published>
    <updated>2009-12-20T19:06:25Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Claudio Poli</title>
<content type="html">&lt;p&gt;Hello,
problem: cookies[session_key] sometimes is blank.&lt;/p&gt;

&lt;p&gt;try deleting the cookie from the browser and do a new request, cookies will not contain the generated value but instead it's blank; even debugging Rack Env shows that the value doesn't exists.&lt;/p&gt;

&lt;p&gt;however the browser at the end of the request will have a full cookie in its cache.&lt;/p&gt;

&lt;p&gt;In my uploader I'm sending the session key value, remember me token from clearance to see if the user is logged in and the authenticity token.&lt;/p&gt;

&lt;p&gt;Now, examining the source afaik auth token and session key value aren't linked, but when the session key is nil and I send the POST request, rails throws the InvalidAuthenticityToken error.&lt;/p&gt;

&lt;p&gt;Also there seems to be another aspect; sometimes even if the session key is there and present and sent along the request, I get InvalidAuthenticityToken, but it's not due to bad escaping issues, but probably because something expires. That's it, at the moment in my app I have &quot;long running&quot; forms that just stay there at user's disposal (uploadify).&lt;/p&gt;

&lt;p&gt;Ideas? Thanks.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11594</id>
    <published>2009-12-11T16:32:34Z</published>
    <updated>2009-12-11T16:32:34Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Ah, more of an internationalisation problem then! Glad you got it sorted :)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>acid</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11593</id>
    <published>2009-12-11T16:04:14Z</published>
    <updated>2009-12-11T16:04:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by acid</title>
<content type="html">&lt;p&gt;Ouch! I've found my error. I'd typed the filename wrong :/
A simple 
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;mv app/middleware/flash_session_cookie_middelware.rb app/middleware/flash_session_cookie_middleware.rb&lt;/code&gt;&lt;/pre&gt; solved the problem, thanks for your patience! :D&lt;/p&gt;

&lt;p&gt;acid&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11591</id>
    <published>2009-12-11T15:08:52Z</published>
    <updated>2009-12-11T15:08:52Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;It really sounds like a problem with the load paths. A few more things to try from the Rails console:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Rails.configuration.load_paths
# =&gt; what's the output?

require 'app/middleware/flash_session_cookie_middleware'
# =&gt; output?

FlashSessionCookieMiddleware
# =&gt; output?

FlashSessionCookieMiddleware.new(nil)
# =&gt; output?&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>acid</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11570</id>
    <published>2009-12-10T16:32:53Z</published>
    <updated>2009-12-10T16:32:53Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by acid</title>
<content type="html">&lt;p&gt;Hmm, interessting. I'm getting the same uninitialized Constant Error as before. Here is the ouput: http://gist.github.com/253436&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11542</id>
    <published>2009-12-09T19:31:11Z</published>
    <updated>2009-12-09T19:31:11Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;If you fire up a Rails console and try and load the class what happens (in other words just type &lt;code&gt;FlashSessionCookieMiddleware&lt;/code&gt; at the prompt)? What about if you try and instantiate it with &lt;code&gt; FlashSessionCookieMiddleware.new(nil)&lt;/code&gt;?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>acid</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11535</id>
    <published>2009-12-09T14:51:04Z</published>
    <updated>2009-12-09T14:51:04Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by acid</title>
<content type="html">&lt;p&gt;@Bertgoethals Jipp, I did. Sorry, that I didn't say that in my previous post. I thought it would be clear as I can load the middleware with &quot; around the classname.&lt;/p&gt;

&lt;p&gt;I also use jruby, if that's a matter.&lt;/p&gt;

&lt;p&gt;acid&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Bertgoethals</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11526</id>
    <published>2009-12-09T08:29:54Z</published>
    <updated>2009-12-09T08:29:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Bertgoethals</title>
<content type="html">&lt;p&gt;@acid Did you add app/middleware to your load path?&lt;/p&gt;

&lt;p&gt;Add this to environment.rb&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;config.load_paths += %W( #{RAILS_ROOT}/app/middleware )&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>acid</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:11509</id>
    <published>2009-12-08T22:07:19Z</published>
    <updated>2009-12-08T22:07:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by acid</title>
<content type="html">&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;many thanks for this great post! I'm trying to build it into my code, but i ran into strange &quot;unitialized Constant: FlashSessionCookieMiddleware&quot; Errors. I tried to circumvent this with this call:&lt;/p&gt;

&lt;p&gt;ActionController::Dispatcher.middleware.insert_before(ActionController::Base.session_store, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key])&lt;/p&gt;

&lt;p&gt;Then it get's loaded into the middleware stack but i get a strange error about  the new() Method on a string.&lt;/p&gt;

&lt;p&gt;More info can be found here: http://bit.ly/7iLCnr&lt;/p&gt;

&lt;p&gt;Have anybody an idea, what i could have done wrong?&lt;/p&gt;

&lt;p&gt;acid&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Bert Goethals</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10829</id>
    <published>2009-11-18T10:52:38Z</published>
    <updated>2009-11-18T10:52:38Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Bert Goethals</title>
<content type="html">&lt;p&gt;I fixed my previous problem. here is the gist: http://gist.github.com/237741&lt;/p&gt;

&lt;p&gt;Basically I changed the cookie setting to:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;env['HTTP_COOKIE'] = [ @session_key, ::Rack::Utils.escape(params[@session_key]) ].join('=').freeze unless params[@session_key].nil?&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The escaping of the value is needed as ::Rack::Utils.parse_query unescapes the value, but the ::Rack::Request.cookie() will unescape the values as well. &lt;/p&gt;

&lt;p&gt;I suggest adding this to the post itself.&lt;/p&gt;

&lt;p&gt;@UVSoft 
Yes, your post makes total sence.&lt;/p&gt;

&lt;p&gt;@Mirko Kirović 
If you send your values as extra post parameters these will not be URL encoded, and thus you should take care that the values end up as encoded in the cookie.
This solution is built for passing sessions via the URL, this does not apply to the POST headers.&lt;/p&gt;

&lt;p&gt;@Ben Reubenstein
Read the manual. When adding the middleware to the stack, use your session_id as the argument, don't change the middleware :p&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Bert Goethals</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10806</id>
    <published>2009-11-17T18:00:52Z</published>
    <updated>2009-11-17T18:00:52Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Bert Goethals</title>
<content type="html">&lt;p&gt;Great article, I've been using a similar technique for a couple of months, but recently I had some users (a fixed, tiny set (not reproducible on staging machines)) getting InvalidAuthenticityToken exceptions.&lt;/p&gt;

&lt;p&gt;So I switched to your solution; but to no avail. &lt;/p&gt;

&lt;p&gt;I have one example session:&lt;/p&gt;

&lt;p&gt;When asking the browser (before the request) what the session is we get: (Note the &quot;+&quot; sign in their that could potentially cause some problems)&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;BAh7CiIYdXNlcl9jcmVkZW50aWFsc19pZGkC+gQiFXVzZXJfY3JlZGVudGlhbHMiAYA3YTY3NTg2YzE3YmE2NGFhYzFhOWRjZmViOWFiZDk1NDQzYzRiMjgxNTQ5MzMzMGUwMzc0NDEzNWNhYWRkMWM2OTg4YTIxYzlhNGRiNDY2ZjY1ZGQxMGZlMGQzODQzYzNhN2M3ZjdkNDcxZDU0ZjM0Mzg5MjYxN2M3ZTFiODM0NjoQX2NzcmZfdG9rZW4iMWdLR2VQQlpCZkphdWxGNW93VVhLb2htV0VYOWdzVWVKY0EreHl0WXZCbDQ9Og9zZXNzaW9uX2lkIiU3MTQzZjIzNjI4YWZhZDliMjM4YTRkMjJmNWUzM2QxYyIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgtzdWNjZXMiKFRoZSBhbGJ1bSB3YXMgc3VjY2Vzc2Z1bGx5IGNyZWF0ZWQuBjoKQHVzZWR7BjsIRg==--6cf3c4385d48b4f182be28a804923dd7d5e6dd75&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is the URI received: (notice the %2B instead of +)&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;users/3/albums/303/images?_younited_session=BAh7CiIYdXNlcl9jcmVkZW50aWFsc19pZGkC%2BgQiFXVzZXJfY3JlZGVudGlhbHMiAYA3YTY3NTg2YzE3YmE2NGFhYzFhOWRjZmViOWFiZDk1NDQzYzRiMjgxNTQ5MzMzMGUwMzc0NDEzNWNhYWRkMWM2OTg4YTIxYzlhNGRiNDY2ZjY1ZGQxMGZlMGQzODQzYzNhN2M3ZjdkNDcxZDU0ZjM0Mzg5MjYxN2M3ZTFiODM0NjoQX2NzcmZfdG9rZW4iMWdLR2VQQlpCZkphdWxGNW93VVhLb2htV0VYOWdzVWVKY0EreHl0WXZCbDQ9Og9zZXNzaW9uX2lkIiU3MTQzZjIzNjI4YWZhZDliMjM4YTRkMjJmNWUzM2QxYyIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgtzdWNjZXMiKFRoZSBhbGJ1bSB3YXMgc3VjY2Vzc2Z1bGx5IGNyZWF0ZWQuBjoKQHVzZWR7BjsIRg%3D%3D--6cf3c4385d48b4f182be28a804923dd7d5e6dd75&amp;amp;authenticity_token=gKGePBZBfJaulF5owUXKohmWEX9gsUeJcA%2BxytYvBl4%3D&amp;amp;image%5Bdescription%5D=&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The params look like this: (notice the + is fixed, duh)&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;{ :authenticity_tokeng =&amp;gt; 'KGePBZBfJaulF5owUXKohmWEX9gsUeJcA+xytYvBl4=', :_younited_session =&amp;gt; 'BAh7CiIYdXNlcl9jcmVkZW50aWFsc19pZGkC+gQiFXVzZXJfY3JlZGVudGlhbHMiAYA3YTY3NTg2YzE3YmE2NGFhYzFhOWRjZmViOWFiZDk1NDQzYzRiMjgxNTQ5MzMzMGUwMzc0NDEzNWNhYWRkMWM2OTg4YTIxYzlhNGRiNDY2ZjY1ZGQxMGZlMGQzODQzYzNhN2M3ZjdkNDcxZDU0ZjM0Mzg5MjYxN2M3ZTFiODM0NjoQX2NzcmZfdG9rZW4iMWdLR2VQQlpCZkphdWxGNW93VVhLb2htV0VYOWdzVWVKY0EreHl0WXZCbDQ9Og9zZXNzaW9uX2lkIiU3MTQzZjIzNjI4YWZhZDliMjM4YTRkMjJmNWUzM2QxYyIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgtzdWNjZXMiKFRoZSBhbGJ1bSB3YXMgc3VjY2Vzc2Z1bGx5IGNyZWF0ZWQuBjoKQHVzZWR7BjsIRg==--6cf3c4385d48b4f182be28a804923dd7d5e6dd75', :image =&amp;gt; { :description =&amp;gt; '' } }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And the session looks like this: (notice the + is fine)&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;_younited_session=BAh7CiIYdXNlcl9jcmVkZW50aWFsc19pZGkC+gQiFXVzZXJfY3JlZGVudGlhbHMiAYA3YTY3NTg2YzE3YmE2NGFhYzFhOWRjZmViOWFiZDk1NDQzYzRiMjgxNTQ5MzMzMGUwMzc0NDEzNWNhYWRkMWM2OTg4YTIxYzlhNGRiNDY2ZjY1ZGQxMGZlMGQzODQzYzNhN2M3ZjdkNDcxZDU0ZjM0Mzg5MjYxN2M3ZTFiODM0NjoQX2NzcmZfdG9rZW4iMWdLR2VQQlpCZkphdWxGNW93VVhLb2htV0VYOWdzVWVKY0EreHl0WXZCbDQ9Og9zZXNzaW9uX2lkIiU3MTQzZjIzNjI4YWZhZDliMjM4YTRkMjJmNWUzM2QxYyIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgtzdWNjZXMiKFRoZSBhbGJ1bSB3YXMgc3VjY2Vzc2Z1bGx5IGNyZWF0ZWQuBjoKQHVzZWR7BjsIRg==--6cf3c4385d48b4f182be28a804923dd7d5e6dd75&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This seems perfect to me, exactly as it should be. Yet This request created an InvalidAuthenticityToken?!&lt;/p&gt;

&lt;p&gt;Can anyone help me out with this one?&lt;/p&gt;

&lt;p&gt;I'm using authlogic, have no additional session/cookie values defined. This is on Rails 2.3.4 with passenger and SWFuploader.&lt;/p&gt;

&lt;p&gt;Thx in advance. &lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10576</id>
    <published>2009-11-10T08:20:15Z</published>
    <updated>2009-11-10T08:20:15Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Yes, the newer Rails authentication tokens include ‘+’ signs which need to be URL encoded. Like @mirko we tend to do it in the view using the &lt;code&gt;u&lt;/code&gt; helper or in JavaScript using the &lt;code&gt;encodeURIComponent&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;The main thing is that you do the encoding &lt;em&gt;somewhere&lt;/em&gt;, otherwise the ‘+’ signs are treated as spaces and then you get &lt;code&gt;InvalidAuthenticityToken&lt;/code&gt; exceptions again, which kind of defeats the purpose of the middleware.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>UVSoft</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10463</id>
    <published>2009-11-08T12:24:43Z</published>
    <updated>2009-11-08T12:24:43Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by UVSoft</title>
<content type="html">&lt;p&gt;Hi!&lt;/p&gt;

&lt;p&gt;First of all thanks for this great article, it is really useful!&lt;/p&gt;

&lt;p&gt;I tried to use this middleware, but anyway I got InvalidAuthenticityToken exception. The behavior was strange, sometimes it worked, sometimes not. I realized that Rails could not restore user session, so new session id was generated in CookieStore middleware. I started researching and found out it was because sometimes cookie contained the plus sign (+), and after our middleware plus turned into space in CookieStore middleware.&lt;/p&gt;

&lt;p&gt;My solution is the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;env['HTTP&lt;em&gt;COOKIE'] = [ @session&lt;/em&gt;key, params[@session&lt;em&gt;key] ].join('=').freeze unless params[@session&lt;/em&gt;key].nil?&lt;/li&gt;
&lt;li&gt;env['HTTP&lt;em&gt;COOKIE'] = [ @session&lt;/em&gt;key, ERB::Util.url&lt;em&gt;encode(params[@session&lt;/em&gt;key]) ].join('=').freeze unless params[@session_key].nil?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Does it make sense?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10168</id>
    <published>2009-11-02T08:19:14Z</published>
    <updated>2009-11-02T08:19:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;@Ben: it sounds like you've passed the session key param wrongly in the &lt;code&gt;new_asset_path_with_session_information&lt;/code&gt;, make sure you're using the local variable as the param key, not a string or a symbol. The second problem you mention is as Trevor describes (thanks Trevor!). I've not had a chance to look at this problem yet, but will do one day ;)&lt;/p&gt;

&lt;p&gt;@Mirko: the need for encodeURIComponent is down to a more recent change in the way Rails generates the authenticity token: I &lt;a href=&quot;http://thewebfellas.com/blog/2009/4/5/encode-url-parameters-in-javascript&quot; title=&quot;Read the blog&quot;&gt;blogged about this&lt;/a&gt; a little while ago.&lt;/p&gt;

&lt;p&gt;The difference between &lt;code&gt;cookies[session_key_name]&lt;/code&gt; and &lt;code&gt;session[:session_id]&lt;/code&gt; is simply because they represent two different things: &lt;code&gt;cookies[session_key_name]&lt;/code&gt; gives you the &lt;strong&gt;entire&lt;/strong&gt; contents of the session cookie, &lt;code&gt;session[:session_id]&lt;/code&gt; simply gives you the ID of the current session. Think of it as the difference between simply saying &lt;code&gt;params&lt;/code&gt; and &lt;code&gt;params[:id]&lt;/code&gt; - the first gives you the entire params hash, the second the value of the &lt;code&gt;:id&lt;/code&gt; parameter.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Mirko Kirovi&#263;</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10167</id>
    <published>2009-11-02T08:06:19Z</published>
    <updated>2009-11-02T08:06:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Mirko Kirovi&#263;</title>
<content type="html">&lt;p&gt;I managed to get this working, but there is something more that bugs me.&lt;/p&gt;

&lt;p&gt;This is taken from my view JS file:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;'&amp;lt;%= session_key_name %&gt;'  : '&amp;lt;%=u cookies[session_key_name] %&gt;',
'authenticity_token'                   : encodeURIComponent('&amp;lt;%=u form_authenticity_token if protect_against_forgery? %&gt;')&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I've noticed that:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;cookies[session_key_name] = BAh7BzoQX2NzcmZfdG9rZW4iMVprWlJ1cWtnUlNTYnVZRjFleHY5ZmN5YWpDRDhqUzk3R2crWStDN2d3S3M9Og9zZXNzaW9uX2lkIiVhNmFmNjhiNTE0MDM4NWVjMjQwNWMwMDM5MDJlNGZkYw%3D%3D--3f4447000a68faa73e3f206a9099d65ca6824d49&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;session[:session_id] = a6af68b5140385ec2405c003902e4fdc&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Huh? Why the difference?&lt;/p&gt;

&lt;p&gt;If I pass &lt;code&gt;cookies[session&lt;em&gt;key&lt;/em&gt;name]&lt;/code&gt; to middleware everything works ok with the code from my previous mail. But not with &lt;code&gt;session[:session_id]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;authenticity_token&lt;/code&gt; is invalid if supplied without &lt;code&gt;encodeURIComponent()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Maybe you should update you post and shed some light on this wierd behaviour.&lt;/p&gt;

&lt;p&gt;Maybe Rails's cookie middleware does some strange things with encoding/decoding?&lt;/p&gt;

&lt;p&gt;Kind regards,
Mirko&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Mirko Kirovi&#263;</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:10166</id>
    <published>2009-11-02T08:02:09Z</published>
    <updated>2009-11-02T08:02:09Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Mirko Kirovi&#263;</title>
<content type="html">&lt;p&gt;Great article.&lt;/p&gt;

&lt;p&gt;I'm sending &lt;em&gt;my_app&lt;/em&gt;session and authenticity token as additional post params with &lt;a href=&quot;http://www.uploadify.com/&quot;&gt;Uploadify&lt;/a&gt;, so I had to change flash&lt;em&gt;session&lt;/em&gt;cookie_middleware.rb to this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;require 'rack/utils'

class FlashSessionCookieMiddleware
  def initialize(app, session_key = '_session_id')
    @app = app
    @session_key = session_key
  end

  def call(env)
    if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
      params = ::Rack::Request.new(env).params
      #params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
      env['HTTP_COOKIE'] = [ @session_key, params[@session_key] ].join('=').freeze unless params[@session_key].nil?
    end
    @app.call(env)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now the error I am receiving is really strange to me (I got used to InvalidAuthenticityToken error):&lt;/p&gt;

&lt;pre&gt;NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.length):
  app/middleware/flash_session_cookie_middleware.rb:15:in `call'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Line 15 is:
    @app.call(env)&lt;/pre&gt;

&lt;p&gt;Any ideas, because I have none?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Trevor Rowe</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:9104</id>
    <published>2009-10-07T15:30:16Z</published>
    <updated>2009-10-07T15:30:16Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Trevor Rowe</title>
<content type="html">&lt;p&gt;I've noticed a nasty little side-effect using the methods described in this blog post.  The flash uploader will fixate on the session you give it.  If your server tries to modify the session during the upload processes the changes to the session are lost (or rather ignored).&lt;/p&gt;

&lt;p&gt;Ben - this would explain issue #2 you are having.&lt;/p&gt;

&lt;p&gt;A little longer explanation:&lt;/p&gt;

&lt;p&gt;When construct the url with the session key and session in the query string, it saves that off.  Each successive request to your upload action will receive the same session.  Because flash is not sharing the session cookies with your browser, changes made to that session in another tab get lost.  The browser will delete the session cookie, but flash is unaware.  If your refresh the page where your session cookie is passed to the flash uploader then it will get the new url with the new embedded-session query string.&lt;/p&gt;

&lt;p&gt;If this behavior is unacceptable, the only solution I can come up with involves send the new session back with every upload response, and then have javascript grab the new session and give a new url to the flash uploader before it makes its next upload request.  Take care to make sure you get the right session.  If you just ask for coookies[session_key] in your controller you will get the old session.  You will need to after you make all of the modifications to session marshell it down into the string that would normally be sent as the cookie string.  You could also just add to the rack middleware and pull the new session out of its headers.&lt;/p&gt;

&lt;p&gt;I haven't tried this yet, any thoughts?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Ben Reubenstein</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8782</id>
    <published>2009-09-21T18:11:23Z</published>
    <updated>2009-09-21T18:11:23Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Ben Reubenstein</title>
<content type="html">&lt;p&gt;Another interesting thing to note that I have not quite figured out yet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In my old code I bypassed protect&lt;em&gt;from&lt;/em&gt;forgery for the upload photos action.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If I logged out of my app in another tab, I could still upload files to the app.  It still took the session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When I removed my protect&lt;em&gt;from&lt;/em&gt;forgery exclusion, the invalid&lt;em&gt;authenticity&lt;/em&gt;token exception was thrown.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Shouldn't the session have been invalid regardless of the invalid token?... &lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Ben Reubenstein</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8781</id>
    <published>2009-09-21T17:35:04Z</published>
    <updated>2009-09-21T17:35:04Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Ben Reubenstein</title>
<content type="html">&lt;p&gt;I had an existing app using swfupload for a while using some cookie hacks.  Upgrading the Rails 2.3.4 with the new Rack session broke it.  This article was valuable in getting it working again, but for some reason params[@session&lt;em&gt;key] was not pulling the value out of the hash in the middleware.  I had to change it to params['session&lt;/em&gt;key'] to pull the value.  Any ideas on why this might happen? I thought it might be a Rails 2.3.4 issue, but when I took the example app out of github and moved it to 2.3.4 everything worked perfectly.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;require 'rack/utils'

class FlashSessionCookieMiddleware
  def initialize(app, session_key = '_session_id')
    @app = app
    @session_key = session_key
  end

  def call(env)
    if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
      params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
      env['HTTP_COOKIE'] = [ @session_key, params['session_key'] ].join('=').freeze unless params['session_key'].nil?
    end
    @app.call(env)
  end
end&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8503</id>
    <published>2009-09-06T11:36:33Z</published>
    <updated>2009-09-06T11:36:33Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Stephen,&lt;/p&gt;

&lt;p&gt;I made a start on a more flexible version of this middleware the other day (I'll blog about it when it's ready for use) and thought to myself &quot;I wonder if I should allow the whole cookie to be preserved?&quot; - so good timing with your comment and I guess the answer to my question is a definite &quot;yes&quot;!&lt;/p&gt;

&lt;p&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Stephen England</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8463</id>
    <published>2009-09-03T11:47:38Z</published>
    <updated>2009-09-03T11:47:38Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Stephen England</title>
<content type="html">&lt;p&gt;Hi Guy's,&lt;/p&gt;

&lt;p&gt;I haved an issue (due to upgrading thoughtbot/clearance to 8.2) where I need to access other cookies from flash. I've solved this by putting all cookies into the query string like so;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def assets_path_with_session_information
    session_key = ActionController::Base.session_options[:key]
    assets_path(request_forgery_protection_token =&amp;gt; form_authenticity_token, :cookies =&amp;gt; cookies)
  end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then in the Middleware pulling them all back out again;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;require 'rack/utils'

class FlashSessionCookieMiddleware
  def initialize(app, session_key = '_session_id')
    @app = app
    @session_key = session_key
  end

  def call(env)
    if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
      params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
      cookies = []
      params.each_pair do |key, value|
        if key =~ /^cookie/
          cookie_key = key[8..-2]
          cookies &amp;lt;&amp;lt; [ cookie_key, value ].join('=').freeze
        end
      end
      env['HTTP_COOKIE'] = cookies.join(';')
    end
    @app.call(env)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Seems to work fine for me. Hope people find it useful :) Please let me know if there is something glaringly wrong with this ;)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ebuyc</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8388</id>
    <published>2009-08-28T18:21:15Z</published>
    <updated>2009-08-28T18:21:15Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by ebuyc</title>
<content type="html">&lt;p&gt;Ok this is what I figured out: flash / flash.now was messing the session up somehow that was from the new person / account creation. I traced it down to the cookie&lt;em&gt;store class, unmarshal(session) failed to verify the cookie. Was hitting generate&lt;/em&gt;sid then when the flash request failed. But then it worked from there on out. Drove me nuts because a normal login was working fine...&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8381</id>
    <published>2009-08-27T22:14:13Z</published>
    <updated>2009-08-27T22:14:13Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;That's ok I managed to get to your &lt;a href=&quot;http://pastie.org/596060&quot; title=&quot;A pastie&quot;&gt;pastie&lt;/a&gt;. &lt;a href=&quot;http://smartic.us/&quot; title=&quot;Go to smartic.us&quot;&gt;Smartic.us&lt;/a&gt; put a nice screencast on using gists over on &lt;a href=&quot;http://www.vimeo.com/1381658&quot; title=&quot;Watch the video&quot;&gt;Vimeo&lt;/a&gt; which you might want to take a look at.&lt;/p&gt;

&lt;p&gt;Looking at the code my main question was how/where the &lt;code&gt;person_being_viewed&lt;/code&gt; object was being initialised? I'd also try tweaking the helper to maybe look a little more like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def person_album_photos_path_with_session_information(person_id, album_id)
  session_key = ActionController::Base.session_options[:key]
  person_album_photos_path(:person_id =&gt; person_id, 
                           :album_id =&gt; album_id, 
                           session_key =&gt; cookies[session_key], 
                           request_forgery_protection_token =&gt; form_authenticity_token,
                           :swf_uploader =&gt; 1)
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This allows you to specify the person_id and album_id when you call the helper (removing the direct reference to the params hash), removes the &lt;code&gt;person_being_viewed.id&lt;/code&gt; default that I was unsure of, and removes the need to do any string concatenation for the &lt;code&gt;swf_uploader&lt;/code&gt; parameter.&lt;/p&gt;

&lt;p&gt;I'm not sure if this will make a difference though as the rest of the helper looks fine to me. Perhaps the session data is getting mangled in the middleware instead of the helper?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ebuyc</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8366</id>
    <published>2009-08-26T22:19:07Z</published>
    <updated>2009-08-26T22:19:07Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by ebuyc</title>
<content type="html">&lt;p&gt;I clearly have never posted styled code nor used gist / pastie before ... Please educate me nicely... thanks.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Poster</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8362</id>
    <published>2009-08-26T19:45:54Z</published>
    <updated>2009-08-26T19:45:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Poster</title>
<content type="html">&lt;p&gt;Rob &amp;amp; lardawge &amp;amp; all: a 1000 thanks :-)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8353</id>
    <published>2009-08-25T22:11:57Z</published>
    <updated>2009-08-25T22:11:57Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;If you want to &lt;a href=&quot;http://gist.github.com/&quot; title=&quot;Post a gist&quot;&gt;post a gist&lt;/a&gt; or &lt;a href=&quot;http://pastie.org/&quot; title=&quot;Post a pastie&quot;&gt;pastie&lt;/a&gt; up the code for your view and controller I'd be happy to take a look tomorrow and see if I can spot anything.&lt;/p&gt;

&lt;p&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ebuyc</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8352</id>
    <published>2009-08-25T19:26:11Z</published>
    <updated>2009-08-25T19:26:11Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by ebuyc</title>
<content type="html">&lt;p&gt;ok recap: 302 / 406 error ff / ie respectively on a new signup, first upload attempt. A refresh and all is good. I see now that even though the :person session id is on the SWFuploader page, it is not on the first flash request which hits the before filter. Now why does this all work for a returning user? And why does it work after a refresh? Still digging, but hope this helps some other running the older restful authentication system and / or similar problems.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ebuyc</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8351</id>
    <published>2009-08-25T18:53:04Z</published>
    <updated>2009-08-25T18:53:04Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by ebuyc</title>
<content type="html">&lt;p&gt;ok everything looks in order, but the digest is changing every page refresh. I assume this is correct behavior? &lt;/p&gt;

&lt;p&gt;And now I see the problem: the initial session_key is really long, but then after a page refresh it changes to about half the length...&lt;/p&gt;

&lt;p&gt;Any thoughts would be greatly appreciated.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ebuyc</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:8350</id>
    <published>2009-08-25T18:10:54Z</published>
    <updated>2009-08-25T18:10:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by ebuyc</title>
<content type="html">&lt;p&gt;I have this working with restful authentication and swfuploader -- THANKS!
.
.
.
  But for a new user I always get a 302 (failed login check before_filter) in FF and a 406 in IE on the first attempt to upload something. One page refresh and all is better. If I don't refresh then any other links force a failed login for all other requests?!. I am just curious if anyone had any similar behavior or thoughts on the matter... thanks digging in now.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Evgeniy Dolzhenko</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:7799</id>
    <published>2009-07-22T17:44:07Z</published>
    <updated>2009-07-22T17:44:07Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Evgeniy Dolzhenko</title>
<content type="html">&lt;p&gt;Thank you very much, 
very useful writeup, successfully integrated SWFUpload with Rails 2.3.2&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:7584</id>
    <published>2009-07-11T22:15:26Z</published>
    <updated>2009-07-11T22:15:26Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;@Zubin: the middleware shouldn't be doing anything unless the request is coming from Flash - could it be something else causing the session mismatch?&lt;/p&gt;

&lt;p&gt;@Pina: What does your form view look like?&lt;/p&gt;

&lt;p&gt;@Tung: thanks for that, I've updated the post to include your more generic code.&lt;/p&gt;

&lt;p&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Tung Nguyen</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:7112</id>
    <published>2009-07-02T19:03:27Z</published>
    <updated>2009-07-02T19:03:27Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Tung Nguyen</title>
<content type="html">&lt;p&gt;Thanks for this great post.&lt;/p&gt;

&lt;p&gt;Ping: &lt;/p&gt;

&lt;p&gt;This is a little more generic for everyone.  We're using :memcache&lt;em&gt;cache&lt;/em&gt;store&lt;/p&gt;

&lt;p&gt;ActionController::Dispatcher.middleware.insert&lt;em&gt;before(ActionController::Base.session&lt;/em&gt;store, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key])&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Pina</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:7076</id>
    <published>2009-07-02T02:55:20Z</published>
    <updated>2009-07-02T02:55:20Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Pina</title>
<content type="html">&lt;p&gt;Hi, i had to change the middleware.insert_before because my middleware stack was a little diferente, so i changed to&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;ActionController::Dispatcher.middleware.insert_before(ActiveRecord::SessionStore, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key])&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So my stack looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;use Rack::Lock
use ActionController::Failsafe
use ActionController::Reloader
use FlashSessionCookieMiddleware, &amp;quot;_lucy2_session&amp;quot;
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActiveRecord::SessionStore, #&amp;lt;Proc:0x024e08ac@(eval):8&amp;gt;
use ActionController::RewindableInput
use ActionController::ParamsParser
use Rack::MethodOverride
use Rack::Head
run ActionController::Dispatcher.new&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But still i'm having the InvalidAuthenticityToken error.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  app/middleware/flash_session_cookie_middleware.rb:16:in `call'&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I'm using rails 2.3.2 with ruby 1.8.
Any thoughts?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Zubin</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:5963</id>
    <published>2009-06-04T20:50:37Z</published>
    <updated>2009-06-04T20:50:37Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Zubin</title>
<content type="html">&lt;p&gt;Nice work! I'd been stuck on this for a while, but one problem remains... any others had this?&lt;/p&gt;

&lt;p&gt;In my app, when logging in via &quot;remember me&quot;, the sessions do not match. Logging in via the login form works. Am using thoughtbot's Clearance gem btw.&lt;/p&gt;

&lt;p&gt;As you can see, session[:session_id] does not match the end of cookies['_myapp_session'].&lt;/p&gt;

&lt;p&gt;I've tried this kludge but it didn't work, nor did it feel &quot;right&quot;.
&lt;code&gt;session[:session_id] = cookies[session_key][-40..-1] if cookies[session_key]&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;samp&gt;--
params
Hash
{&quot;format&quot;=&gt;&quot;json&quot;, &quot;folder&quot;=&gt;&quot;/&quot;, &quot;authenticity_token&quot;=&gt;&quot;tkR0ZBNgsbx6CNoGXmn9YDgn7nBrwPjnnVM2e75NKNU=&quot;, &quot;_myapp_session&quot;=&gt;&quot;BAh7CDoQX2NzcmZfdG9rZW4iMXRrUjBaQk5nc2J4NkNOb0dYbW45WURnbjduQnJ3UGpublZNMmU3NU5LTlU9IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsAOg9zZXNzaW9uX2lkIiU4MTMwZmNmZDhkY2Y3MTI2ZDYwZWI0NzE3ZTllZWU3Ng==--e2363b6614cd3d678218c7e14c435c01b130c031&quot;}
.../app/middleware/flash_session_cookie_middleware.rb
--
cookies
ActionController::CookieJar
{&quot;_myapp_session&quot;=&gt;&quot;BAh7CDoQX2NzcmZfdG9rZW4iMXRrUjBaQk5nc2J4NkNOb0dYbW45WURnbjduQnJ3UGpublZNMmU3NU5LTlU9IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsAOg9zZXNzaW9uX2lkIiU4MTMwZmNmZDhkY2Y3MTI2ZDYwZWI0NzE3ZTllZWU3Ng==--e2363b6614cd3d678218c7e14c435c01b130c031&quot;}
.../app/controllers/assets_controller.rb
--
session
ActionController::Session::AbstractStore::SessionHash
{:_csrf_token=&gt;&quot;tkR0ZBNgsbx6CNoGXmn9YDgn7nBrwPjnnVM2e75NKNU=&quot;, &quot;flash&quot;=&gt;{}, :session_id=&gt;&quot;8130fcfd8dcf7126d60eb4717e9eee76&quot;}
.../app/controllers/assets_controller.rb&lt;/samp&gt;&lt;/pre&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:5881</id>
    <published>2009-06-02T08:06:49Z</published>
    <updated>2009-06-02T08:06:49Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;I’ve just added some extra information for getting this middleware working on Rails 2.3.2.&lt;/p&gt;

&lt;p&gt;@tom: you might want to take a look as it will likely solve your InvalidAuthenticityToken errors&lt;/p&gt;

&lt;p&gt;@david: thanks for the email with the updates!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>David North</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:5357</id>
    <published>2009-05-21T19:18:27Z</published>
    <updated>2009-05-21T19:18:27Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by David North</title>
<content type="html">&lt;p&gt;I'm pretty sure this approach doesn't work in Rails 2.3.2 because CookieStore, which is a kind of middleware too now, gets its call method called before this custom Middleware, so the contents of env['HTTP_COOKIE'] never gets processed.&lt;/p&gt;

&lt;p&gt;I've been able to confirm that my value (after middleware processing) of env['HTTP_COOKIE'] is identical for both regular requests, and Flash ones, but for Flash the session doesn't get restored.&lt;/p&gt;

&lt;p&gt;Perhaps there's a way to force this middleware ahead of the Rails stuff?&lt;/p&gt;

&lt;p&gt;Thanks, David&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Tom</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:5198</id>
    <published>2009-05-18T12:51:15Z</published>
    <updated>2009-05-18T12:51:15Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Tom</title>
<content type="html">&lt;p&gt;Argh!  This solution works great SOMETIMES.  I haven't been able to figure out the circumstances, but sometimes when the flash posts the data I still get a InvalidAuthenticityToken.  I have been able to reproduce the error and noticed that if I refresh the page over and over, eventually the session and authenticity token will work.  The authenticity token doesn,t change but the session data does.  I was beginning to think the issue was related to page caching, but I have verified that even a new user can experience this intermittent issue.  Does anyone have any ideas of where I should look?&lt;/p&gt;

&lt;p&gt;I am using the swfuploader with the middleware code above.&lt;/p&gt;

&lt;p&gt;Thanks,
Tom&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:4771</id>
    <published>2009-05-10T15:45:53Z</published>
    <updated>2009-05-10T15:45:53Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;@Lee: sorry I didn't see your question sooner. As you've found out Rails didn't get all of it's Rack goodness until 2.3 so and upgrade is the easiest way to take advantage of middleware like this.&lt;br /&gt;Glad you got it working!&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Shih-gian Lee</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:4689</id>
    <published>2009-05-08T15:05:46Z</published>
    <updated>2009-05-08T15:05:46Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Shih-gian Lee</title>
<content type="html">&lt;p&gt;I upgraded to Rails 2.3 and will take a look at the example provided by David North. The error is gone. Thanks to both for the great solution!&lt;/p&gt;

&lt;p&gt;Thanks,
Lee&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>shih-gian Lee</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:4572</id>
    <published>2009-05-05T15:39:14Z</published>
    <updated>2009-05-05T15:39:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by shih-gian Lee</title>
<content type="html">&lt;p&gt;Hi Rob,&lt;/p&gt;

&lt;p&gt;Thank you for the great solution. I am working with Ruby 1.8 and Rails 2.1. I have installed the rack via gem. But, I am getting the following error:&lt;/p&gt;

&lt;p&gt;/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:275:in &lt;code&gt;load_missing_constant': uninitialized constant ActionController::Dispatcher (NameError)
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in&lt;/code&gt;const_missing'
    from /Users/shihgianlee/work/ror/beautifulworld/config/initializers/session_store.rb:6
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in &lt;code&gt;load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in&lt;/code&gt;load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in &lt;code&gt;new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in&lt;/code&gt;load'
    from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:475:in &lt;code&gt;load_application_initializers'
    from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:474:in&lt;/code&gt;each'
     ... 31 levels...
    from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in &lt;code&gt;gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in&lt;/code&gt;require'
    from script/server:3&lt;/p&gt;

&lt;p&gt;Any help is much appreciated.&lt;/p&gt;

&lt;p&gt;Thanks,
Lee&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:4197</id>
    <published>2009-04-20T07:26:00Z</published>
    <updated>2009-04-20T07:26:00Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi David,&lt;br /&gt;
What about in your Rails app, if you inspect the params hash in your controller has it been mangled in some way or does it contain what it should?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>David North</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:4081</id>
    <published>2009-04-15T13:15:02Z</published>
    <updated>2009-04-15T13:15:02Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by David North</title>
<content type="html">&lt;p&gt;I still get InvalidAuthenticityToken although I've verified that the correct authenticity token is appearing in the query string params in the middleware like so:&lt;/p&gt;

&lt;p&gt;params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
puts params.inspect&lt;/p&gt;

&lt;p&gt;Which shows:
{&quot;_session_id&quot;=&gt;&quot;61ff4979bdcf3d92c71ef0620c3260d5&quot;, &quot;authenticity_token&quot;=&gt;&quot;m++g6vKEMIUq7n7ZEHkrI7XIV1YKnLbLWI/ZXEpXGhk=&quot;}&lt;/p&gt;

&lt;p&gt;Any ideas?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3806</id>
    <published>2009-04-07T07:03:46Z</published>
    <updated>2009-04-07T07:03:46Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Jakob,&lt;br /&gt;
If you mean in the &lt;code&gt;new_asset_path_with_session_information&lt;/code&gt; helper then no they shouldn't be symbols. The &lt;code&gt;session_key =&gt; ...&lt;/code&gt; means we want to use the name of the session key obtained from the ActionController session options (for example '_my_app_session') and the &lt;code&gt;request_forgery_protection_token =&gt; ...&lt;/code&gt; means we want to use the name of the CSRF parameter (for example 'authenticity_token').&lt;/p&gt;

&lt;p&gt;Hope that makes sense!&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Jakob</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3779</id>
    <published>2009-04-06T11:37:08Z</published>
    <updated>2009-04-06T11:37:08Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Jakob</title>
<content type="html">&lt;p&gt;Hi, thanks for the nice post! Just a question, shouldn't the session_key and request_forgery_protection be symbols? :session_key =&gt; ...&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>lardawge</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3419</id>
    <published>2009-03-19T17:34:55Z</published>
    <updated>2009-03-19T17:34:55Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by lardawge</title>
<content type="html">&lt;p&gt;Very cool! Must have just hit google cuz I couldn't find it before... I have forked and updated a sample rails app that uses attachment_fu and swfupload to include your code. http://tiny.cc/swfuploadrailsauthentication credit goes to cameronyule for the original project... Thanks again!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3209</id>
    <published>2009-03-03T17:48:37Z</published>
    <updated>2009-03-03T17:48:37Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Thanks Saimon, I've updated the post.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Saimon Moore</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3208</id>
    <published>2009-03-03T14:11:17Z</published>
    <updated>2009-03-03T14:11:17Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Saimon Moore</title>
<content type="html">&lt;p&gt;Another little fix: http://gist.github.com/73328&lt;/p&gt;

&lt;p&gt;Saimon&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3063</id>
    <published>2009-02-12T08:21:52Z</published>
    <updated>2009-02-12T08:21:52Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Rob Anderton</title>
<content type="html">&lt;p&gt;Good catch - I've updated the code to check for the session key param, thanks!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Yaroslav</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3058</id>
    <published>2009-02-11T13:25:30Z</published>
    <updated>2009-02-11T13:25:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by Yaroslav</title>
<content type="html">&lt;p&gt;Little correction: http://gist.github.com/62006&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>yaroslav</name>
    </author>
    <id>tag:thewebfellas.com,2008-12-22:2691:3051</id>
    <published>2009-02-10T17:44:36Z</published>
    <updated>2009-02-10T17:44:36Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue" rel="alternate" type="text/html"/>
    <title>Comment on 'Flash uploaders, Rails, cookie based sessions and CSRF: Rack Middleware to the rescue!' by yaroslav</title>
<content type="html">&lt;p&gt;Big thanks for the writeup.&lt;/p&gt;</content>  </entry>
</feed>
