mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
SECURITY: The SSO return_path
was an open redirect
This security fix needs SSO to be configured, and the user has to go through the entire auth process before being redirected to the wrong host so it is probably lower priority for most installs.
This commit is contained in:
@ -26,6 +26,8 @@ describe SessionController do
|
||||
@sso_url = "http://somesite.com/discourse_sso"
|
||||
@sso_secret = "shjkfdhsfkjh"
|
||||
|
||||
request.host = Discourse.current_hostname
|
||||
|
||||
SiteSetting.enable_sso = true
|
||||
SiteSetting.sso_url = @sso_url
|
||||
SiteSetting.sso_secret = @sso_secret
|
||||
@ -79,7 +81,39 @@ describe SessionController do
|
||||
|
||||
logged_on_user = Discourse.current_user_provider.new(request.env).current_user
|
||||
expect(logged_on_user.admin).to eq(true)
|
||||
end
|
||||
|
||||
it 'redirects to a non-relative url' do
|
||||
sso = get_sso("#{Discourse.base_url}/b/")
|
||||
sso.external_id = '666' # the number of the beast
|
||||
sso.email = 'bob@bob.com'
|
||||
sso.name = 'Sam Saffron'
|
||||
sso.username = 'sam'
|
||||
|
||||
get :sso_login, Rack::Utils.parse_query(sso.payload)
|
||||
expect(response).to redirect_to('/b/')
|
||||
end
|
||||
|
||||
it 'redirects to root if the host of the return_path is different' do
|
||||
sso = get_sso('//eviltrout.com')
|
||||
sso.external_id = '666' # the number of the beast
|
||||
sso.email = 'bob@bob.com'
|
||||
sso.name = 'Sam Saffron'
|
||||
sso.username = 'sam'
|
||||
|
||||
get :sso_login, Rack::Utils.parse_query(sso.payload)
|
||||
expect(response).to redirect_to('/')
|
||||
end
|
||||
|
||||
it 'redirects to root if the host of the return_path is different' do
|
||||
sso = get_sso('http://eviltrout.com')
|
||||
sso.external_id = '666' # the number of the beast
|
||||
sso.email = 'bob@bob.com'
|
||||
sso.name = 'Sam Saffron'
|
||||
sso.username = 'sam'
|
||||
|
||||
get :sso_login, Rack::Utils.parse_query(sso.payload)
|
||||
expect(response).to redirect_to('/')
|
||||
end
|
||||
|
||||
it 'allows you to create an account' do
|
||||
|
Reference in New Issue
Block a user