diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab_net.rb | 22 | ||||
-rw-r--r-- | lib/gitlab_shell.rb | 9 |
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 |