Rename ignore .gpg-id switch to enalbe .gpg-id
This commit is contained in:
parent
f539d2ccfc
commit
b49593e87f
5 changed files with 21 additions and 21 deletions
|
|
@ -46,12 +46,12 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
return uiSwitch
|
return uiSwitch
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let ignoreGPGIDSwitch: UISwitch = {
|
let enableGPGIDSwitch: UISwitch = {
|
||||||
let uiSwitch = UISwitch()
|
let uiSwitch = UISwitch()
|
||||||
uiSwitch.onTintColor = Colors.systemBlue
|
uiSwitch.onTintColor = Colors.systemBlue
|
||||||
uiSwitch.sizeToFit()
|
uiSwitch.sizeToFit()
|
||||||
uiSwitch.addTarget(self, action: #selector(ignoreGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||||
uiSwitch.isOn = Defaults.isIgnoreGPGIDOn
|
uiSwitch.isOn = Defaults.isEnableGPGIDOn
|
||||||
return uiSwitch
|
return uiSwitch
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
|
|
||||||
// section 2
|
// section 2
|
||||||
[
|
[
|
||||||
[.title: "IgnoreGPGID".localize(), .action: "none"],
|
[.title: "EnableGPGID".localize(), .action: "none"],
|
||||||
[.title: "ShowFolders".localize(), .action: "none"],
|
[.title: "ShowFolders".localize(), .action: "none"],
|
||||||
[.title: "HidePasswordImages".localize(), .action: "none"],
|
[.title: "HidePasswordImages".localize(), .action: "none"],
|
||||||
[.title: "HideUnknownFields".localize(), .action: "none"],
|
[.title: "HideUnknownFields".localize(), .action: "none"],
|
||||||
|
|
@ -139,10 +139,10 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
cell.accessoryType = .none
|
cell.accessoryType = .none
|
||||||
cell.selectionStyle = .none
|
cell.selectionStyle = .none
|
||||||
cell.accessoryView = showFolderSwitch
|
cell.accessoryView = showFolderSwitch
|
||||||
case "IgnoreGPGID".localize():
|
case "EnableGPGID".localize():
|
||||||
cell.accessoryType = .none
|
cell.accessoryType = .none
|
||||||
cell.selectionStyle = .none
|
cell.selectionStyle = .none
|
||||||
cell.accessoryView = ignoreGPGIDSwitch
|
cell.accessoryView = enableGPGIDSwitch
|
||||||
case "HidePasswordImages".localize():
|
case "HidePasswordImages".localize():
|
||||||
cell.accessoryType = .none
|
cell.accessoryType = .none
|
||||||
let detailButton = UIButton(type: .detailDisclosure)
|
let detailButton = UIButton(type: .detailDisclosure)
|
||||||
|
|
@ -221,8 +221,8 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
func ignoreGPGIDSwitchAction(_: Any?) {
|
func enableGPGIDSwitchAction(_: Any?) {
|
||||||
Defaults.isIgnoreGPGIDOn = ignoreGPGIDSwitch.isOn
|
Defaults.isEnableGPGIDOn = enableGPGIDSwitch.isOn
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
"PasswordGeneratorFlavor" = "Style";
|
"PasswordGeneratorFlavor" = "Style";
|
||||||
"RememberPgpKeyPassphrase" = "Remember PGP Key Passphrase";
|
"RememberPgpKeyPassphrase" = "Remember PGP Key Passphrase";
|
||||||
"RememberGitCredentialPassphrase" = "Remember Git Credential Passphrase";
|
"RememberGitCredentialPassphrase" = "Remember Git Credential Passphrase";
|
||||||
"IgnoreGPGID" = "Ignore .gpg-id";
|
"EnableGPGID" = "Enable .gpg-id (Experiment)";
|
||||||
"ShowFolders" = "Show Folders";
|
"ShowFolders" = "Show Folders";
|
||||||
"HidePasswordImages" = "Hide Password Images";
|
"HidePasswordImages" = "Hide Password Images";
|
||||||
"HidePasswordImagesExplanation." = "Associated favicon images are loaded and shown based upon the URL associated with an entry. Enable this option to hide these images and prevent them from being loaded.";
|
"HidePasswordImagesExplanation." = "Associated favicon images are loaded and shown based upon the URL associated with an entry. Enable this option to hide these images and prevent them from being loaded.";
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public extension DefaultsKeys {
|
||||||
var isHideOTPOn: DefaultsKey<Bool> { .init("isHideOTPOn", defaultValue: false) }
|
var isHideOTPOn: DefaultsKey<Bool> { .init("isHideOTPOn", defaultValue: false) }
|
||||||
var isRememberPGPPassphraseOn: DefaultsKey<Bool> { .init("isRememberPGPPassphraseOn", defaultValue: false) }
|
var isRememberPGPPassphraseOn: DefaultsKey<Bool> { .init("isRememberPGPPassphraseOn", defaultValue: false) }
|
||||||
var isRememberGitCredentialPassphraseOn: DefaultsKey<Bool> { .init("isRememberGitCredentialPassphraseOn", defaultValue: false) }
|
var isRememberGitCredentialPassphraseOn: DefaultsKey<Bool> { .init("isRememberGitCredentialPassphraseOn", defaultValue: false) }
|
||||||
var isIgnoreGPGIDOn: DefaultsKey<Bool> { .init("isIgnoreGPGIDOn", defaultValue: true) }
|
var isEnableGPGIDOn: DefaultsKey<Bool> { .init("isEnableGPGIDOn", defaultValue: false) }
|
||||||
var isShowFolderOn: DefaultsKey<Bool> { .init("isShowFolderOn", defaultValue: true) }
|
var isShowFolderOn: DefaultsKey<Bool> { .init("isShowFolderOn", defaultValue: true) }
|
||||||
var isHidePasswordImagesOn: DefaultsKey<Bool> { .init("isHidePasswordImagesOn", defaultValue: false) }
|
var isHidePasswordImagesOn: DefaultsKey<Bool> { .init("isHidePasswordImagesOn", defaultValue: false) }
|
||||||
var searchDefault: DefaultsKey<SearchBarScope?> { .init("searchDefault", defaultValue: .all) }
|
var searchDefault: DefaultsKey<SearchBarScope?> { .init("searchDefault", defaultValue: .all) }
|
||||||
|
|
|
||||||
|
|
@ -691,11 +691,11 @@ public class PasswordStore {
|
||||||
let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath())
|
let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath())
|
||||||
let encryptedData = try Data(contentsOf: encryptedDataPath)
|
let encryptedData = try Data(contentsOf: encryptedDataPath)
|
||||||
let data: Data? = try {
|
let data: Data? = try {
|
||||||
if Defaults.isIgnoreGPGIDOn {
|
if Defaults.isEnableGPGIDOn {
|
||||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
|
||||||
} else {
|
|
||||||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||||
|
} else {
|
||||||
|
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
guard let decryptedData = data else {
|
guard let decryptedData = data else {
|
||||||
|
|
@ -710,20 +710,20 @@ public class PasswordStore {
|
||||||
guard let passwordEntity = fetchPasswordEntity(with: path) else {
|
guard let passwordEntity = fetchPasswordEntity(with: path) else {
|
||||||
throw AppError.decryption
|
throw AppError.decryption
|
||||||
}
|
}
|
||||||
if Defaults.isIgnoreGPGIDOn {
|
if Defaults.isEnableGPGIDOn {
|
||||||
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
|
||||||
} else {
|
|
||||||
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||||
|
} else {
|
||||||
|
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encrypt(password: Password, keyID: String? = nil) throws -> Data {
|
public func encrypt(password: Password, keyID: String? = nil) throws -> Data {
|
||||||
let encryptedDataPath = storeURL.appendingPathComponent(password.url.path)
|
let encryptedDataPath = storeURL.appendingPathComponent(password.url.path)
|
||||||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||||
if Defaults.isIgnoreGPGIDOn {
|
if Defaults.isEnableGPGIDOn {
|
||||||
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
|
||||||
} else {
|
|
||||||
return try PGPAgent.shared.encrypt(plainData: password.plainData, keyID: keyID)
|
return try PGPAgent.shared.encrypt(plainData: password.plainData, keyID: keyID)
|
||||||
|
} else {
|
||||||
|
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class PasswordStoreTest: XCTestCase {
|
||||||
|
|
||||||
func testCloneAndDecryptMultiKeys() throws {
|
func testCloneAndDecryptMultiKeys() throws {
|
||||||
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
|
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
|
||||||
Defaults.isIgnoreGPGIDOn = false
|
Defaults.isEnableGPGIDOn = true
|
||||||
let passwordStore = PasswordStore(url: url)
|
let passwordStore = PasswordStore(url: url)
|
||||||
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
|
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
|
||||||
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil)
|
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil)
|
||||||
|
|
@ -47,7 +47,7 @@ class PasswordStoreTest: XCTestCase {
|
||||||
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
|
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
|
||||||
|
|
||||||
passwordStore.erase()
|
passwordStore.erase()
|
||||||
Defaults.isIgnoreGPGIDOn = true
|
Defaults.isEnableGPGIDOn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
|
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue