{"issue":{"created_at":"2011-12-01T03:50:03Z","state":"open","updated_at":"2011-12-01T04:08:12Z","comments":1,"user":{"gravatar_id":"7fd56fa98da45bc532e898132085bd05","id":7591,"url":"https://api.github.com/users/jferris","avatar_url":"https://secure.gravatar.com/avatar/7fd56fa98da45bc532e898132085bd05?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jferris"},"body":"This moves most of the stuff from `Clearance::Authentication` into a `Clearance::Session` object, and delegates from the controllers to that. A piece of Rack middleware injects the session object into the Rack environment hash.\r\n\r\nThis lets you keep using the same methods in Rails controllers, but provides `env[:clearance]` for Rack middleware/apps you might be using. This is summed up pretty well in the README changes I made: https://github.com/thoughtbot/clearance/commit/f845887dd3431d31a2e201161a8e0000ff0446fa#diff-1\r\n\r\nThe major reason I want to do this is to move more things out of Rails action filters and into middleware. Things like Saucy's account filters, Kissmetrics and identity handling, and so on can all move into middleware this way. I find middleware easier to deal with in general, particularly in tests.\r\n\r\nThis also starts us down the road of making it easier to introduce alternative authentication methods, which has historically been a pain in Clearance, since we can make a new piece of middleware that injects its own session. A little refactoring of `Clearance::Session` would make that much easier.\r\n\r\nThe only downside I can find to this is that Rails functional tests don't go through the middleware stack by default. That means that, out of the box, this branch won't work with functional tests as-is. You'll need to require `clearance/testing` to make them work. We could try to automatically include the helpers if we think that's a problem.","assignee":null,"id":2410709,"number":177,"labels":[],"pull_request":{"patch_url":"https://github.com/thoughtbot/clearance/pull/177.patch","html_url":"https://github.com/thoughtbot/clearance/pull/177","diff_url":"https://github.com/thoughtbot/clearance/pull/177.diff"},"title":"Perform authentication in Rack middleware","closed_at":null,"html_url":"https://github.com/thoughtbot/clearance/issues/177","url":"https://api.github.com/repos/thoughtbot/clearance/issues/177","milestone":null},"action":"created","comment":{"created_at":"2011-12-01T04:08:12Z","updated_at":"2011-12-01T04:08:12Z","user":{"gravatar_id":"8e2b996de3842c6ef7e68a82fa5f01f5","id":198,"url":"https://api.github.com/users/croaky","avatar_url":"https://secure.gravatar.com/avatar/8e2b996de3842c6ef7e68a82fa5f01f5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"croaky"},"body":"Looks good to me. Couple of style questions.","id":2970604,"url":"https://api.github.com/repos/thoughtbot/clearance/issues/comments/2970604"}}