Commit 3280c094 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ee-api-guard' into 'master'

Introduce EE::API::APIGuard::HelperMethods

See merge request gitlab-org/gitlab-ee!4378
parents 5c34451b 173e17e5
module EE
module API
module APIGuard
module HelperMethods
extend ::Gitlab::Utils::Override
override :find_user_from_sources
def find_user_from_sources
find_user_from_access_token ||
find_user_from_job_token ||
find_user_from_warden
end
end
end
end
end
......@@ -39,10 +39,11 @@ module API
# Helper Methods for Grape Endpoint
module HelperMethods
prepend EE::API::APIGuard::HelperMethods
include Gitlab::Auth::UserAuthFinders
def find_current_user!
user = find_user_from_access_token || find_user_from_job_token || find_user_from_warden
user = find_user_from_sources
return unless user
forbidden!('User is blocked') unless Gitlab::UserAccess.new(user).allowed? && user.can?(:access_api)
......@@ -50,6 +51,10 @@ module API
user
end
def find_user_from_sources
find_user_from_access_token || find_user_from_warden
end
private
# An array of scopes that were registered (using `allow_access_with_scope`)
......
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