mirror of
https://gitea.com/gitea/tea.git
synced 2026-02-22 06:13:32 +01:00
Revert "Login requires a http/https login URL and revmoe SSH as a login method. SSH will be optional (#826)" (#891)
This reverts commit 90f8624ae7.
Fixes: #890
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/891
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Michal Suchanek <msuchanek@suse.de>
Co-committed-by: Michal Suchanek <msuchanek@suse.de>
This commit is contained in:
committed by
Lunny Xiao
parent
3595f8f89d
commit
e644cc49d4
@@ -86,7 +86,7 @@ func CreateLogin() error {
|
||||
|
||||
printTitleAndContent("Name of new Login: ", name)
|
||||
|
||||
loginMethod, err := promptSelectV2("Login with: ", []string{"token", "oauth"})
|
||||
loginMethod, err := promptSelectV2("Login with: ", []string{"token", "ssh-key/certificate", "oauth"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func CreateLogin() error {
|
||||
printTitleAndContent("Allow Insecure connections:", strconv.FormatBool(insecure))
|
||||
|
||||
return auth.OAuthLoginWithOptions(name, giteaURL, insecure)
|
||||
case "token":
|
||||
default: // token
|
||||
var hasToken bool
|
||||
if err := huh.NewConfirm().
|
||||
Title("Do you have an access token?").
|
||||
@@ -154,7 +154,7 @@ func CreateLogin() error {
|
||||
Value(&tokenScopes).
|
||||
Validate(func(s []string) error {
|
||||
if len(s) == 0 {
|
||||
return errors.New("at least one scope is required")
|
||||
return errors.New("At least one scope is required")
|
||||
}
|
||||
return nil
|
||||
}).
|
||||
@@ -176,36 +176,26 @@ func CreateLogin() error {
|
||||
}
|
||||
printTitleAndContent("OTP (if applicable):", otp)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown login method: %s", loginMethod)
|
||||
}
|
||||
|
||||
var optSettings bool
|
||||
if err := huh.NewConfirm().
|
||||
Title("Set Optional settings:").
|
||||
Value(&optSettings).
|
||||
WithTheme(theme.GetTheme()).
|
||||
Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
printTitleAndContent("Set Optional settings:", strconv.FormatBool(optSettings))
|
||||
|
||||
if optSettings {
|
||||
pubKeys := task.ListSSHPubkey()
|
||||
emptyOpt := "Auto-discovery SSH Key in ~/.ssh and ssh-agent"
|
||||
pubKeys = append([]string{emptyOpt}, pubKeys...)
|
||||
|
||||
sshKey, err = promptSelect("Select ssh-key: ", pubKeys, "", "", "")
|
||||
if err != nil {
|
||||
case "ssh-key/certificate":
|
||||
if err := huh.NewInput().
|
||||
Title("SSH Key/Certificate Path (leave empty for auto-discovery in ~/.ssh and ssh-agent):").
|
||||
Value(&sshKey).
|
||||
WithTheme(theme.GetTheme()).
|
||||
Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
if sshKey == emptyOpt {
|
||||
sshKey = ""
|
||||
}
|
||||
printTitleAndContent("SSH Key/Certificate Path (leave empty for auto-discovery in ~/.ssh and ssh-agent):", sshKey)
|
||||
|
||||
printTitleAndContent("SSH Key Path (leave empty for auto-discovery) in ~/.ssh and ssh-agent):", sshKey)
|
||||
|
||||
if sshKey != "" {
|
||||
if sshKey == "" {
|
||||
pubKeys := task.ListSSHPubkey()
|
||||
if len(pubKeys) == 0 {
|
||||
fmt.Println("No SSH keys found in ~/.ssh or ssh-agent")
|
||||
return nil
|
||||
}
|
||||
sshKey, err = promptSelect("Select ssh-key: ", pubKeys, "", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printTitleAndContent("Selected ssh-key:", sshKey)
|
||||
|
||||
// ssh certificate
|
||||
@@ -229,6 +219,27 @@ func CreateLogin() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var optSettings bool
|
||||
if err := huh.NewConfirm().
|
||||
Title("Set Optional settings:").
|
||||
Value(&optSettings).
|
||||
WithTheme(theme.GetTheme()).
|
||||
Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
printTitleAndContent("Set Optional settings:", strconv.FormatBool(optSettings))
|
||||
|
||||
if optSettings {
|
||||
if err := huh.NewInput().
|
||||
Title("SSH Key Path (leave empty for auto-discovery):").
|
||||
Value(&sshKey).
|
||||
WithTheme(theme.GetTheme()).
|
||||
Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
printTitleAndContent("SSH Key Path (leave empty for auto-discovery):", sshKey)
|
||||
|
||||
if err := huh.NewConfirm().
|
||||
Title("Allow Insecure connections:").
|
||||
|
||||
Reference in New Issue
Block a user