Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes #148 - Trailing slashes are stripped from request and callback…

… paths.
  • Loading branch information...
commit 14e35fd99492e03e00d528eaca8937f3e9d21b35 1 parent 894954a
Michael Bleigh authored
View
12 oa-core/lib/omniauth/strategy.rb
@@ -27,11 +27,11 @@ def call!(env)
@env = env
return mock_call!(env) if OmniAuth.config.test_mode
- if request.path == request_path
+ if current_path == request_path
status, headers, body = *call_app!
@response = Rack::Response.new(body, status, headers)
request_phase
- elsif request.path == callback_path
+ elsif current_path == callback_path
callback_phase
else
if respond_to?(:other_phase)
@@ -43,9 +43,9 @@ def call!(env)
end
def mock_call!(env)
- if request.path == request_path
+ if current_path == request_path
redirect callback_path
- elsif request.path == callback_path
+ elsif current_path == callback_path
@env['omniauth.auth'] = OmniAuth.mock_auth_for(name.to_sym)
call_app!
else
@@ -75,6 +75,10 @@ def callback_path
options[:callback_path] || "#{path_prefix}/#{name}/callback"
end
+ def current_path
+ request.path.sub(/\/$/,'')
+ end
+
def query_string
request.query_string.empty? ? "" : "?#{request.query_string}"
end
View
8 oa-core/spec/omniauth/strategy_spec.rb
@@ -39,6 +39,14 @@ def callback_phase
lambda{ strategy.call({'PATH_INFO' => '/auth/test/callback'}) }.should raise_error("Callback Phase")
end
+ it 'should strip trailing spaces on request' do
+ lambda{ strategy.call({'PATH_INFO' => '/auth/test/'}) }.should raise_error("Request Phase")
+ end
+
+ it 'should strip trailing spaces on callback' do
+ lambda{ strategy.call({'PATH_INFO' => '/auth/test/callback/'}) }.should raise_error("Callback Phase")
+ end
+
context 'callback_url' do
it 'uses the default callback_path' do
strategy.should_receive(:full_host).and_return('http://example.com')
Please sign in to comment.
Something went wrong with that request. Please try again.