Login requires a http/https login URL and revmoe SSH as a login method. SSH will be optional (#826)

Fix #825

Reviewed-on: https://gitea.com/gitea/tea/pulls/826
This commit is contained in:
Lunny Xiao
2025-10-18 23:09:27 +00:00
parent 61d4e571a7
commit 90f8624ae7
4 changed files with 41 additions and 59 deletions

View File

@@ -14,25 +14,21 @@ func ValidateAuthenticationMethod(
token string,
user string,
passwd string,
sshAgent bool,
sshKey string,
sshCertPrincipal string,
) (*url.URL, error) {
// Normalize URL
serverURL, err := NormalizeURL(giteaURL)
if err != nil {
return nil, fmt.Errorf("Unable to parse URL: %s", err)
return nil, fmt.Errorf("unable to parse URL: %s", err)
}
if !sshAgent && sshCertPrincipal == "" && sshKey == "" {
// .. if we have enough information to authenticate
if len(token) == 0 && (len(user)+len(passwd)) == 0 {
return nil, fmt.Errorf("No token set")
} else if len(user) != 0 && len(passwd) == 0 {
return nil, fmt.Errorf("No password set")
} else if len(user) == 0 && len(passwd) != 0 {
return nil, fmt.Errorf("No user set")
}
// .. if we have enough information to authenticate
if len(token) == 0 && (len(user)+len(passwd)) == 0 {
return nil, fmt.Errorf("no token set")
} else if len(user) != 0 && len(passwd) == 0 {
return nil, fmt.Errorf("no password set")
} else if len(user) == 0 && len(passwd) != 0 {
return nil, fmt.Errorf("no user set")
}
return serverURL, nil
}