Changes after rebase
This commit is contained in:
parent
b810f479d5
commit
7f0317917a
|
|
@ -39,7 +39,7 @@ module API
|
|||
|
||||
# Helper Methods for Grape Endpoint
|
||||
module HelperMethods
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
include Gitlab::Auth::UserAuthFinders
|
||||
|
||||
def find_current_user!
|
||||
user = find_user_from_access_token || find_user_from_warden
|
||||
|
|
@ -50,25 +50,6 @@ module API
|
|||
user
|
||||
end
|
||||
|
||||
def access_token
|
||||
strong_memoize(:access_token) do
|
||||
find_oauth_access_token || find_personal_access_token
|
||||
end
|
||||
end
|
||||
|
||||
def validate_access_token!(scopes: [])
|
||||
return unless access_token
|
||||
|
||||
case AccessTokenValidationService.new(access_token, request: request).validate(scopes: scopes)
|
||||
when AccessTokenValidationService::INSUFFICIENT_SCOPE
|
||||
raise InsufficientScopeError.new(scopes)
|
||||
when AccessTokenValidationService::EXPIRED
|
||||
raise ExpiredError
|
||||
when AccessTokenValidationService::REVOKED
|
||||
raise RevokedError
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# An array of scopes that were registered (using `allow_access_with_scope`)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ module Gitlab
|
|||
end
|
||||
|
||||
module UserAuthFinders
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
|
||||
PRIVATE_TOKEN_HEADER = 'HTTP_PRIVATE_TOKEN'.freeze
|
||||
PRIVATE_TOKEN_PARAM = :private_token
|
||||
|
||||
|
|
@ -60,9 +62,9 @@ module Gitlab
|
|||
private
|
||||
|
||||
def access_token
|
||||
return @access_token if defined?(@access_token)
|
||||
|
||||
@access_token = find_oauth_access_token || find_personal_access_token
|
||||
strong_memoize(:access_token) do
|
||||
find_oauth_access_token || find_personal_access_token
|
||||
end
|
||||
end
|
||||
|
||||
def find_personal_access_token
|
||||
|
|
|
|||
Loading…
Reference in New Issue