Merge branch 'fix_pat_auth-11-4' into 'security-11-4'
[11.4] Fix Token lookup for Git over HTTP and registry authentication See merge request gitlab/gitlabhq!2577
This commit is contained in:
parent
5091cc4f77
commit
c847f172d2
3 changed files with 3 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
class PersonalAccessTokensFinder
|
||||
attr_accessor :params
|
||||
|
||||
delegate :build, :find, :find_by, to: :execute
|
||||
delegate :build, :find, :find_by, :find_by_token, to: :execute
|
||||
|
||||
def initialize(params = {})
|
||||
@params = params
|
||||
|
|
|
@ -463,7 +463,7 @@ class User < ActiveRecord::Base
|
|||
def find_by_personal_access_token(token_string)
|
||||
return unless token_string
|
||||
|
||||
PersonalAccessTokensFinder.new(state: 'active').find_by(token: token_string)&.user # rubocop: disable CodeReuse/Finder
|
||||
PersonalAccessTokensFinder.new(state: 'active').find_by_token(token_string)&.user # rubocop: disable CodeReuse/Finder
|
||||
end
|
||||
|
||||
# Returns a user for the given SSH key.
|
||||
|
|
|
@ -151,17 +151,15 @@ module Gitlab
|
|||
end
|
||||
# rubocop: enable CodeReuse/ActiveRecord
|
||||
|
||||
# rubocop: disable CodeReuse/ActiveRecord
|
||||
def personal_access_token_check(password)
|
||||
return unless password.present?
|
||||
|
||||
token = PersonalAccessTokensFinder.new(state: 'active').find_by(token: password)
|
||||
token = PersonalAccessTokensFinder.new(state: 'active').find_by_token(password)
|
||||
|
||||
if token && valid_scoped_token?(token, available_scopes)
|
||||
Gitlab::Auth::Result.new(token.user, nil, :personal_access_token, abilities_for_scopes(token.scopes))
|
||||
end
|
||||
end
|
||||
# rubocop: enable CodeReuse/ActiveRecord
|
||||
|
||||
def valid_oauth_token?(token)
|
||||
token && token.accessible? && valid_scoped_token?(token, [:api])
|
||||
|
|
Loading…
Reference in a new issue