Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-28 03:06:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-28 03:06:20 +0300
commite08eba1838cb749b8815c7da98a504ff97bcfb98 (patch)
tree0172bc4d205f59dd6f3722b27d53e6aa8abb5825 /lib
parentd4633b0e70ec39583ce0b13f277f990b216ac0d9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/auth.rb17
-rw-r--r--lib/gitlab/lfs_token.rb15
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index 53c1398d6ab..ecba0ffbc46 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -231,7 +231,7 @@ module Gitlab
authentication_abilities =
if token_handler.user?
- full_authentication_abilities
+ read_write_project_authentication_abilities
elsif token_handler.deploy_key_pushable?(project)
read_write_authentication_abilities
else
@@ -272,10 +272,21 @@ module Gitlab
]
end
- def read_only_authentication_abilities
+ def read_only_project_authentication_abilities
[
:read_project,
- :download_code,
+ :download_code
+ ]
+ end
+
+ def read_write_project_authentication_abilities
+ read_only_project_authentication_abilities + [
+ :push_code
+ ]
+ end
+
+ def read_only_authentication_abilities
+ read_only_project_authentication_abilities + [
:read_container_image
]
end
diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb
index 124e34562c1..e90f3f05a33 100644
--- a/lib/gitlab/lfs_token.rb
+++ b/lib/gitlab/lfs_token.rb
@@ -34,8 +34,11 @@ module Gitlab
HMACToken.new(actor).token(DEFAULT_EXPIRE_TIME)
end
+ # When the token is an lfs one and the actor
+ # is blocked or the password has been changed,
+ # the token is no longer valid
def token_valid?(token_to_check)
- HMACToken.new(actor).token_valid?(token_to_check)
+ HMACToken.new(actor).token_valid?(token_to_check) && valid_user?
end
def deploy_key_pushable?(project)
@@ -46,6 +49,12 @@ module Gitlab
user? ? :lfs_token : :lfs_deploy_token
end
+ def valid_user?
+ return true unless user?
+
+ !actor.blocked? && (!actor.allow_password_authentication? || !actor.password_expired?)
+ end
+
def authentication_payload(repository_http_path)
{
username: actor_name,
@@ -55,6 +64,10 @@ module Gitlab
}
end
+ def basic_encoding
+ ActionController::HttpAuthentication::Basic.encode_credentials(actor_name, token)
+ end
+
private # rubocop:disable Lint/UselessAccessModifier
class HMACToken