Permalink
Browse files

redirect back to original path to clear openid query string

  • Loading branch information...
1 parent bc9d5a4 commit 6330efa7ce8c7cdf3a1d83414795a96eae1f684f @josh josh committed Jul 25, 2010
Showing with 14 additions and 3 deletions.
  1. +11 −1 lib/rack/openid/simple_auth.rb
  2. +3 −2 test/test_openid.rb
@@ -1,4 +1,5 @@
require 'rack/openid'
+require 'rack/request'
module Rack #:nodoc:
class OpenID
@@ -26,7 +27,7 @@ def call(env)
app.call(env)
elsif successful_response?(env)
authenticate_session(env)
- app.call(env)
+ redirect_to requested_url(env)
else
authentication_request
end
@@ -55,6 +56,15 @@ def successful_response?(env)
end
end
+ def requested_url(env)
+ req = Rack::Request.new(env)
+ req.url
+ end
+
+ def redirect_to(url)
+ [303, {'Content-Type' => 'text/html', 'Location' => url}, []]
+ end
+
def authentication_request
[401, { OpenID::AUTHENTICATE_HEADER => www_authenticate_header }, []]
end
View
@@ -270,12 +270,13 @@ def test_successful_login
process '/dashboard'
follow_redirect!
- assert_equal 200, @response.status
- assert_equal 'Hello', @response.body
+ assert_equal 303, @response.status
+ assert_equal 'http://example.org/dashboard', @response.headers['Location']
cookie = @response.headers['Set-Cookie'].split(';').first
process '/dashboard', 'HTTP_COOKIE' => cookie
assert_equal 200, @response.status
+ assert_equal 'Hello', @response.body
end
def test_failed_login

0 comments on commit 6330efa

Please sign in to comment.