diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-19 13:50:28 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-19 13:50:28 +0200 |
commit | dc2968546500af4ea17dd23f851f00e002290bcc (patch) | |
tree | 032ff527d6aa66a485420bfea307f4ba77e6ae4a | |
parent | 6d43c95b7011ec7ec4600e00bdc8df76bb39813c (diff) | |
download | gitlab-ce-dc2968546500af4ea17dd23f851f00e002290bcc.tar.gz |
Properly support Gitlab::Auth::Result
-rw-r--r-- | lib/gitlab/auth.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/auth/result.rb | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 7464d6082cb..0a0f1c3b17b 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -12,7 +12,7 @@ module Gitlab user_with_password_for_git(login, password) || oauth_access_token_check(login, password) || personal_access_token_check(login, password) || - Result.new + Gitlab::Auth::Result.new rate_limit!(ip, success: result.success?, login: login) @@ -70,7 +70,7 @@ module Gitlab service = project.public_send("#{underscored_service}_service") if service && service.activated? && service.valid_token?(password) - Result.new(nil, project, :ci, build_authentication_abilities) + Gitlab::Auth::Result.new(nil, project, :ci, build_authentication_abilities) end end end @@ -81,7 +81,7 @@ module Gitlab raise Gitlab::Auth::MissingPersonalTokenError if user.two_factor_enabled? - Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities) + Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities) end def oauth_access_token_check(login, password) @@ -89,7 +89,7 @@ module Gitlab token = Doorkeeper::AccessToken.by_token(password) if token && token.accessible? user = User.find_by(id: token.resource_owner_id) - Result.new(user, nil, :oauth, read_authentication_abilities) + Gitlab::Auth::Result.new(user, nil, :oauth, read_authentication_abilities) end end end @@ -98,7 +98,7 @@ module Gitlab if login && password user = User.find_by_personal_access_token(password) validation = User.by_login(login) - Result.new(user, nil, :personal_token, full_authentication_abilities) if user.present? && user == validation + Gitlab::Auth::Result.new(user, nil, :personal_token, full_authentication_abilities) if user.present? && user == validation end end @@ -112,10 +112,10 @@ module Gitlab if build.user # If user is assigned to build, use restricted credentials of user - Result.new(build.user, build.project, :build, build_authentication_abilities) + Gitlab::Auth::Result.new(build.user, build.project, :build, build_authentication_abilities) else # Otherwise use generic CI credentials (backward compatibility) - Result.new(nil, build.project, :ci, build_authentication_abilities) + Gitlab::Auth::Result.new(nil, build.project, :ci, build_authentication_abilities) end end diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb index bf625649cbf..3ec5765b6b0 100644 --- a/lib/gitlab/auth/result.rb +++ b/lib/gitlab/auth/result.rb @@ -1,6 +1,6 @@ module Gitlab module Auth - Result = Struct.new(:actor, :project, :type, :authentication_abilities) do + class Result < Struct.new(:actor, :project, :type, :authentication_abilities) def ci? type == :ci end |