Commit 1c759ded authored by Gosia Ksionek's avatar Gosia Ksionek Committed by Imre Farkas

Refactor git http controller to stop referencing auth::result.actor directly -...

Refactor git http controller to stop referencing auth::result.actor directly - refactor auth result class
parent e036915f
...@@ -33,7 +33,7 @@ module Repositories ...@@ -33,7 +33,7 @@ module Repositories
end end
def authenticate_user def authenticate_user
@authentication_result = Gitlab::Auth::Result.new @authentication_result = Gitlab::Auth::Result::EMPTY
if allow_basic_auth? && basic_auth_provided? if allow_basic_auth? && basic_auth_provided?
login, password = user_name_and_password(request) login, password = user_name_and_password(request)
......
...@@ -53,7 +53,7 @@ module Gitlab ...@@ -53,7 +53,7 @@ module Gitlab
personal_access_token_check(password, project) || personal_access_token_check(password, project) ||
deploy_token_check(login, password, project) || deploy_token_check(login, password, project) ||
user_with_password_for_git(login, password) || user_with_password_for_git(login, password) ||
Gitlab::Auth::Result.new Gitlab::Auth::Result::EMPTY
rate_limit!(rate_limiter, success: result.success?, login: login) rate_limit!(rate_limiter, success: result.success?, login: login)
look_to_limit_user(result.actor) look_to_limit_user(result.actor)
......
...@@ -2,8 +2,17 @@ ...@@ -2,8 +2,17 @@
module Gitlab module Gitlab
module Auth module Auth
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do class Result
self::EMPTY = self.new(nil, nil, nil, nil).freeze attr_reader :actor, :project, :type, :authentication_abilities
def initialize(actor, project, type, authentication_abilities)
@actor = actor
@project = project
@type = type
@authentication_abilities = authentication_abilities
end
EMPTY = self.new(nil, nil, nil, nil).freeze
def ci?(for_project) def ci?(for_project)
type == :ci && type == :ci &&
...@@ -27,6 +36,7 @@ module Gitlab ...@@ -27,6 +36,7 @@ module Gitlab
def auth_user def auth_user
actor.is_a?(User) ? actor : nil actor.is_a?(User) ? actor : nil
end end
alias_method :user, :auth_user
def deploy_token def deploy_token
actor.is_a?(DeployToken) ? actor : nil actor.is_a?(DeployToken) ? actor : nil
......
This diff is collapsed.
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