Commit dab03e73 authored by James Edwards-Jones's avatar James Edwards-Jones

Prevent access to Group SAML metadata/SLO endpoints

These have not been tested with the unique requirements of per-group SAML
and have not yet been verified for security

In particular, these will likely allow someone to determine
if a group exists or not by guessing the name.
parent 5a9ee3b0
...@@ -21,6 +21,12 @@ module OmniAuth ...@@ -21,6 +21,12 @@ module OmniAuth
super super
end end
# Prevent access to SLO and metadata endpoints
# These will need addtional work to securely support
def other_phase
call_app!
end
def self.callback?(env) def self.callback?(env)
env['PATH_INFO'] =~ Gitlab::PathRegex.saml_callback_regex env['PATH_INFO'] =~ Gitlab::PathRegex.saml_callback_regex
end end
......
...@@ -60,7 +60,7 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do ...@@ -60,7 +60,7 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do
end end
end end
it 'returns 404 when if group is not found' do it 'returns 404 when the group is not found' do
expect do expect do
post "/groups/not-a-group/-/saml/callback", SAMLResponse: saml_response post "/groups/not-a-group/-/saml/callback", SAMLResponse: saml_response
end.to raise_error(ActionController::RoutingError) end.to raise_error(ActionController::RoutingError)
...@@ -92,7 +92,7 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do ...@@ -92,7 +92,7 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do
end.to raise_error(ActionController::RoutingError) end.to raise_error(ActionController::RoutingError)
end end
it 'returns 404 when if group is not found' do it 'returns 404 when the group is not found' do
expect do expect do
post '/users/auth/group_saml', group_path: 'not-a-group' post '/users/auth/group_saml', group_path: 'not-a-group'
end.to raise_error(ActionController::RoutingError) end.to raise_error(ActionController::RoutingError)
...@@ -104,4 +104,34 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do ...@@ -104,4 +104,34 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do
end.to raise_error(ActionController::RoutingError) end.to raise_error(ActionController::RoutingError)
end end
end end
describe 'POST /users/auth/group_saml/metadata' do
it 'returns 404 when the group is not found' do
post '/users/auth/group_saml/metadata', group_path: 'not-a-group'
expect(last_response).to be_not_found
end
it 'returns 404 to avoid disclosing group existence' do
post '/users/auth/group_saml/metadata', group_path: 'my-group'
expect(last_response).to be_not_found
end
end
describe 'POST /users/auth/group_saml/slo' do
it 'returns 404 to avoid disclosing group existence' do
post '/users/auth/group_saml/slo', group_path: 'my-group'
expect(last_response).to be_not_found
end
end
describe 'POST /users/auth/group_saml/spslo' do
it 'returns 404 to avoid disclosing group existence' do
post '/users/auth/group_saml/spslo', group_path: 'my-group'
expect(last_response).to be_not_found
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment