complete SSH Key authentication
This commit is contained in:
parent
7a3f05701b
commit
62e2a7fe89
4 changed files with 15 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
@IBOutlet weak var passwordTextField: UITextField!
|
||||
@IBOutlet weak var authenticationTableViewCell: UITableViewCell!
|
||||
|
||||
var authenticationMethod = "Password"
|
||||
var authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
|
@ -26,7 +26,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
}
|
||||
usernameTextField.text = Defaults[.gitRepositoryUsername]
|
||||
passwordTextField.text = Defaults[.gitRepositoryPassword]
|
||||
authenticationTableViewCell.detailTextLabel?.text = Defaults[.gitRepositoryAuthenticationMethod]
|
||||
authenticationTableViewCell.detailTextLabel?.text = authenticationMethod
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,11 @@ class PasswordStore {
|
|||
if Defaults[.pgpKeyID] != "" {
|
||||
pgp.importKeys(fromFile: Globals.shared.secringPath, allowDuplicates: false)
|
||||
}
|
||||
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositoryPassword]))
|
||||
if Defaults[.gitRepositoryAuthenticationMethod] == "Password" {
|
||||
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositoryPassword]))
|
||||
} else {
|
||||
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Defaults[.gitRepositorySSHPublicKeyURL]!, privateKeyFile: Defaults[.gitRepositorySSHPrivateKeyURL]!))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class SSHKeySettingTableViewController: UITableViewController {
|
|||
target: self,
|
||||
action: #selector(doneButtonTapped(_:)))
|
||||
navigationItem.rightBarButtonItem = doneBarButtonItem
|
||||
navigationItem.title = "SSH Key"
|
||||
}
|
||||
|
||||
func doneButtonTapped(_ sender: UIButton) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class SettingsTableViewController: UITableViewController {
|
|||
let gitRepostiroyURL = controller.gitRepositoryURLTextField.text!
|
||||
let username = controller.usernameTextField.text!
|
||||
let password = controller.passwordTextField.text!
|
||||
let auth = controller.authenticationTableViewCell.detailTextLabel!.text!
|
||||
let auth = controller.authenticationMethod
|
||||
|
||||
|
||||
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
|
||||
|
|
@ -34,7 +34,12 @@ class SettingsTableViewController: UITableViewController {
|
|||
if Defaults[.gitRepositoryURL] == nil || gitRepostiroyURL != Defaults[.gitRepositoryURL]!.absoluteString {
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
SVProgressHUD.show(withStatus: "Prepare Repository")
|
||||
let gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password))
|
||||
var gitCredential: GitCredential
|
||||
if Defaults[.gitRepositoryAuthenticationMethod] == "Password" {
|
||||
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password))
|
||||
} else {
|
||||
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Defaults[.gitRepositorySSHPublicKeyURL]!, privateKeyFile: Defaults[.gitRepositorySSHPrivateKeyURL]!))
|
||||
}
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let ret = PasswordStore.shared.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue