mirror of
https://github.com/discourse/discourse.git
synced 2025-09-08 12:06:51 +08:00
Improve redirect avoidance for /sso paths
e6b3310577
was missing an ege case
where return url included current_hostname
This commit is contained in:
parent
7a53e0b186
commit
3ae4fcd1f7
2 changed files with 14 additions and 1 deletions
|
@ -162,7 +162,11 @@ class SessionController < ApplicationController
|
||||||
if return_path !~ /^\/[^\/]/
|
if return_path !~ /^\/[^\/]/
|
||||||
begin
|
begin
|
||||||
uri = URI(return_path)
|
uri = URI(return_path)
|
||||||
return_path = path("/") unless SiteSetting.sso_allows_all_return_paths || uri.host == Discourse.current_hostname
|
if (uri.hostname == Discourse.current_hostname)
|
||||||
|
return_path = uri.request_uri
|
||||||
|
elsif !SiteSetting.sso_allows_all_return_paths
|
||||||
|
return_path = path("/")
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
return_path = path("/")
|
return_path = path("/")
|
||||||
end
|
end
|
||||||
|
|
|
@ -311,6 +311,15 @@ RSpec.describe SessionController do
|
||||||
|
|
||||||
get "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headers
|
get "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headers
|
||||||
expect(response).to redirect_to('/')
|
expect(response).to redirect_to('/')
|
||||||
|
|
||||||
|
sso = get_sso("http://#{Discourse.current_hostname}/sso?bla=1")
|
||||||
|
sso.email = user.email
|
||||||
|
sso.external_id = 'abc'
|
||||||
|
sso.username = 'sam'
|
||||||
|
|
||||||
|
get "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headers
|
||||||
|
expect(response).to redirect_to('/')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can take over an account' do
|
it 'can take over an account' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue