Commit 09c4d8e0 authored by James Lopez's avatar James Lopez

Remove user auth logic

parent d9823a42
......@@ -10,8 +10,7 @@ module EE
def find_user_from_sources
find_user_from_access_token ||
find_user_from_job_token ||
find_user_from_warden ||
find_user_from_scim_token
find_user_from_warden
end
end
end
......
......@@ -22,29 +22,6 @@ module EE
job.user
end
def find_oauth_access_token
return if scim_request?
super
end
def find_user_from_scim_token
return unless scim_request?
token = Doorkeeper::OAuth::Token.from_request(current_request, *Doorkeeper.configuration.access_token_methods)
return unless token
# TODO Use `ScimOauthAccessToken`
scim_token = PersonalAccessToken.find_by_token(token)
raise ::Gitlab::Auth::UnauthorizedError unless scim_token
scim_token.user
end
def scim_request?
current_request.path.starts_with?("/api/scim/")
end
end
end
end
......
......@@ -64,25 +64,4 @@ describe Gitlab::Auth::UserAuthFinders do
it_behaves_like 'find user from job token'
end
end
describe '#find_user_from_scim_token' do
let(:token) { create(:personal_access_token, user: user) }
before do
allow(request).to receive(:path).and_return('/api/scim/')
allow(self).to receive(:current_request).and_return(request)
end
it "returns an Unauthorized exception for an invalid token" do
env['HTTP_AUTHORIZATION'] = "Bearer invalid"
expect { find_user_from_scim_token }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
it "return user if token is valid" do
env['HTTP_AUTHORIZATION'] = "Bearer #{token.token}"
expect(find_user_from_scim_token).to eq(user)
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