summaryrefslogtreecommitdiffstats
path: root/modules/migrations
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2020-09-15 14:32:14 -0500
committerGitHub <noreply@github.com>2020-09-15 15:32:14 -0400
commitd9085fe176d1df1e34f8702858e367dfcf4d90c4 (patch)
tree2279e109bf853eba67ac1dda74a990ce5a9d11b9 /modules/migrations
parent0d14c2fb93491ddc121d8616e7ae2edbe6290ae4 (diff)
downloadgitea-d9085fe176d1df1e34f8702858e367dfcf4d90c4.tar.gz
gitea-d9085fe176d1df1e34f8702858e367dfcf4d90c4.zip
Fix anonymous GL migration (#12862)
* Fix anonymous GL migration Signed-off-by: jolheiser <john.olheiser@gmail.com> * Rely on password instead Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/migrations')
-rw-r--r--modules/migrations/gitlab.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go
index e6529af9de..7ed3d5645f 100644
--- a/modules/migrations/gitlab.go
+++ b/modules/migrations/gitlab.go
@@ -76,9 +76,10 @@ type GitlabDownloader struct {
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
var gitlabClient *gitlab.Client
var err error
- if token != "" {
- gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
- } else {
+ gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
+ // Only use basic auth if token is blank and password is NOT
+ // Basic auth will fail with empty strings, but empty token will allow anonymous public API usage
+ if token == "" && password != "" {
gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL))
}