summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-11-08 00:26:14 +0000
committerNick Thomas <nick@gitlab.com>2018-11-08 00:26:14 +0000
commita44b30f7f96ab39f98cf12a57f973ff51941141c (patch)
treea83d262d697d3d5265716ddd8bf7650870063eca /lib
parent9cf3334cb5cdf871266a2b9538589e36efd788e1 (diff)
parent1c6a8d1d70c1603c73fb9bcb8f440dbf97988e89 (diff)
downloadgitlab-shell-a44b30f7f96ab39f98cf12a57f973ff51941141c.tar.gz
Merge branch 'ashmckenzie/8114-geo-push-ssh-lfs-http-auth-bug' into 'master'
Include LFS operation when requesting auth See merge request gitlab-org/gitlab-shell!254
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_net.rb22
-rw-r--r--lib/gitlab_shell.rb9
2 files changed, 13 insertions, 18 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index ac98e9f..bba68f3 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -53,28 +53,22 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
JSON.parse(resp.body) rescue nil
end
- def lfs_authenticate(gl_id, repo)
+ def lfs_authenticate(gl_id, repo, operation)
id_sym, _, id = self.class.parse_who(gl_id)
+ params = { project: sanitize_path(repo), operation: operation }
- if id_sym == :key_id
- params = {
- project: sanitize_path(repo),
- key_id: id
- }
- elsif id_sym == :user_id
- params = {
- project: sanitize_path(repo),
- user_id: id
- }
+ case id_sym
+ when :key_id
+ params[:key_id] = id
+ when :user_id
+ params[:user_id] = id
else
raise ArgumentError, "lfs_authenticate() got unsupported GL_ID='#{gl_id}'!"
end
resp = post("#{internal_api_endpoint}/lfs_authenticate", params)
- if resp.code == '200'
- GitlabLfsAuthentication.build_from_json(resp.body)
- end
+ GitlabLfsAuthentication.build_from_json(resp.body) if resp.code == '200'
end
def broadcast_message
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 57c70f5..6ad67c1 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -155,8 +155,9 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
if @command == 'git-lfs-authenticate'
GitlabMetrics.measure('lfs-authenticate') do
- $logger.info('Processing LFS authentication', user: log_username)
- lfs_authenticate
+ operation = args[2]
+ $logger.info('Processing LFS authentication', operation: operation, user: log_username)
+ lfs_authenticate(operation)
end
return
end
@@ -224,8 +225,8 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
@config.audit_usernames ? username : "user with id #{@gl_id}"
end
- def lfs_authenticate
- lfs_access = api.lfs_authenticate(@gl_id, @repo_name)
+ def lfs_authenticate(operation)
+ lfs_access = api.lfs_authenticate(@gl_id, @repo_name, operation)
return unless lfs_access