diff options
Diffstat (limited to 'lib/api/api_guard.rb')
-rw-r--r-- | lib/api/api_guard.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index c6557fce541..4b87861a3de 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -43,7 +43,6 @@ module API # Helper Methods for Grape Endpoint module HelperMethods - prepend_if_ee('EE::API::APIGuard::HelperMethods') # rubocop: disable Cop/InjectEnterpriseEditionModule include Gitlab::Auth::AuthFinders def access_token @@ -66,7 +65,7 @@ module API def find_user_from_sources deploy_token_from_request || - find_user_from_access_token || + find_user_from_bearer_token || find_user_from_job_token || find_user_from_warden end @@ -153,7 +152,14 @@ module API { scope: e.scopes }) end - response.finish + status, headers, body = response.finish + + # Grape expects a Rack::Response + # (https://github.com/ruby-grape/grape/commit/c117bff7d22971675f4b34367d3a98bc31c8fc02), + # so we need to recreate the response again even though + # response.finish already does this. + # (https://github.com/nov/rack-oauth2/blob/40c9a99fd80486ccb8de0e4869ae384547c0d703/lib/rack/oauth2/server/abstract/error.rb#L26). + Rack::Response.new(body, status, headers) end end end |