Commit 6408aab2 authored by Nick Thomas's avatar Nick Thomas

Fix LFS push mirroring for mirrors set up a long time ago

We discovered this on our own gitlab-foss -> github mirror. Where the
credentials were generated a long time ago, they don't contain an
`auth_method`. That means the method is `password`. It would be nicer
to keep the details of that within the `RemoteMirror` class, but that
would ban direct access to the `credentials` hash.

Changelog: fixed
parent 2293a29e
---
title: Fix LFS push mirroring for mirrors set up a long time ago
merge_request: 59972
author:
type: fixed
......@@ -97,7 +97,10 @@ module Gitlab
end
def basic_auth
return unless credentials[:auth_method] == "password"
# Some legacy credentials have a nil auth_method, which means password
# https://gitlab.com/gitlab-org/gitlab/-/issues/328674
return unless credentials.fetch(:auth_method, 'password') == 'password'
return if credentials.empty?
{ username: credentials[:user], password: credentials[:password] }
end
......
......@@ -6,7 +6,7 @@ RSpec.describe Gitlab::Lfs::Client do
let(:base_url) { "https://example.com" }
let(:username) { 'user' }
let(:password) { 'password' }
let(:credentials) { { user: username, password: password, auth_method: 'password' } }
let(:credentials) { { user: username, password: password } }
let(:git_lfs_content_type) { 'application/vnd.git-lfs+json' }
let(:git_lfs_user_agent) { "GitLab #{Gitlab::VERSION} LFS client" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment