summaryrefslogtreecommitdiff
path: root/lib/gitlab/auth.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/auth.rb')
-rw-r--r--lib/gitlab/auth.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index b2ef04d23d7..fedbbaf6bb1 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -65,7 +65,7 @@ module Gitlab
authenticators = []
if user
- authenticators << Gitlab::Auth::OAuth::Provider.authentication(user, 'database')
+ authenticators << Gitlab::Auth::OAuth::Provider.authentication(user, "database")
# Add authenticators for all identities if user is not nil
user&.identities&.each do |identity|
@@ -119,14 +119,14 @@ module Gitlab
return unless project && matched_login.present?
- underscored_service = matched_login['service'].underscore
+ underscored_service = matched_login["service"].underscore
if Service.available_services_names.include?(underscored_service)
# We treat underscored_service as a trusted input because it is included
# in the Service.available_services_names whitelist.
service = project.public_send("#{underscored_service}_service") # rubocop:disable GitlabSecurity/PublicSend
- if service && service.activated? && service.valid_token?(password)
+ if service&.activated? && service&.valid_token?(password)
Gitlab::Auth::Result.new(nil, project, :ci, build_authentication_abilities)
end
end
@@ -157,7 +157,7 @@ module Gitlab
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))
@@ -165,7 +165,7 @@ module Gitlab
end
def valid_oauth_token?(token)
- token && token.accessible? && valid_scoped_token?(token, [:api])
+ token&.accessible? && valid_scoped_token?(token, [:api])
end
def valid_scoped_token?(token, scopes)
@@ -176,12 +176,12 @@ module Gitlab
abilities_by_scope = {
api: full_authentication_abilities,
read_registry: [:read_container_image],
- read_repository: [:download_code]
+ read_repository: [:download_code],
}
- scopes.flat_map do |scope|
+ scopes.flat_map { |scope|
abilities_by_scope.fetch(scope.to_sym, [])
- end.uniq
+ }.uniq
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -231,7 +231,7 @@ module Gitlab
end
def build_access_token_check(login, password)
- return unless login == 'gitlab-ci-token'
+ return unless login == "gitlab-ci-token"
return unless password
build = find_build_by_token(password)
@@ -254,7 +254,7 @@ module Gitlab
:read_project,
:build_download_code,
:build_read_container_image,
- :build_create_container_image
+ :build_create_container_image,
]
end
@@ -262,20 +262,20 @@ module Gitlab
[
:read_project,
:download_code,
- :read_container_image
+ :read_container_image,
]
end
def read_write_authentication_abilities
read_authentication_abilities + [
:push_code,
- :create_container_image
+ :create_container_image,
]
end
def full_authentication_abilities
read_write_authentication_abilities + [
- :admin_container_image
+ :admin_container_image,
]
end