mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-20 00:07:22 +01:00
Add ability disable the SSH comment via settings
This commit is contained in:
@@ -62,6 +62,9 @@ struct Secretive: App {
|
||||
}
|
||||
SidebarCommands()
|
||||
}
|
||||
Settings {
|
||||
SettingsView()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2510,6 +2510,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"General" : {
|
||||
|
||||
},
|
||||
"no_secure_storage_description" : {
|
||||
"localizations" : {
|
||||
@@ -2702,6 +2705,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"None" : {
|
||||
|
||||
},
|
||||
"persist_authentication_accept_button" : {
|
||||
"comment" : "When the user authorizes an action using a secret that requires unlock, they're shown a notification offering to leave the secret unlocked for a set period of time. This is the title for the notification.",
|
||||
@@ -3415,6 +3421,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Settings" : {
|
||||
|
||||
},
|
||||
"setup_agent_activity_monitor_description" : {
|
||||
"localizations" : {
|
||||
@@ -4464,6 +4473,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SSH Public Key Comment" : {
|
||||
|
||||
},
|
||||
"SSH public keys can be extended with an arbitrary comment string without changing the meaning of the key." : {
|
||||
|
||||
},
|
||||
"unnamed_secret" : {
|
||||
"extractionState" : "manual",
|
||||
|
||||
@@ -4,6 +4,7 @@ import SecretKit
|
||||
struct SecretDetailView<SecretType: Secret>: View {
|
||||
|
||||
@State var secret: SecretType
|
||||
@AppStorage("com.maxgoedjen.Secretive.commentStyle") var style: CommentStyle = .keyAndHost
|
||||
|
||||
private let keyWriter = OpenSSHKeyWriter()
|
||||
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory().replacingOccurrences(of: Bundle.main.hostBundleID, with: Bundle.main.agentBundleID))
|
||||
@@ -42,9 +43,13 @@ struct SecretDetailView<SecretType: Secret>: View {
|
||||
}
|
||||
|
||||
var keyString: String {
|
||||
keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
|
||||
switch style {
|
||||
case CommentStyle.none:
|
||||
keyWriter.openSSHString(secret: secret, comment: "")
|
||||
default:
|
||||
keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
57
Sources/Secretive/Views/SettingsView.swift
Normal file
57
Sources/Secretive/Views/SettingsView.swift
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// SettingsView.swift
|
||||
// Secretive
|
||||
//
|
||||
// Created by Paul Heidekrüger on 05.02.24.
|
||||
// Copyright © 2024 Max Goedjen. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum CommentStyle: String, CaseIterable, Identifiable {
|
||||
case keyAndHost, none
|
||||
var id: Self { self }
|
||||
}
|
||||
|
||||
struct GeneralSettingsView: View {
|
||||
@AppStorage("com.maxgoedjen.Secretive.commentStyle") var selectedCommentStyle: CommentStyle = .keyAndHost
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Section(footer: Text("SSH public keys can be extended with an arbitrary comment string without changing the meaning of the key.")
|
||||
.font(.caption)
|
||||
.fontWeight(.light)) {
|
||||
Picker("SSH Public Key Comment", selection: $selectedCommentStyle) {
|
||||
Text("Default").tag(CommentStyle.keyAndHost)
|
||||
Text("None").tag(CommentStyle.none)
|
||||
}
|
||||
.pickerStyle(DefaultPickerStyle())
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 350, height: 100)
|
||||
.navigationTitle("Settings")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct SettingsView: View {
|
||||
private enum Tabs: Hashable {
|
||||
case general
|
||||
}
|
||||
var body: some View {
|
||||
TabView {
|
||||
GeneralSettingsView()
|
||||
.tabItem {
|
||||
Label("General", systemImage: "gear")
|
||||
}
|
||||
.tag(Tabs.general)
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 500, height: 200)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SettingsView()
|
||||
}
|
||||
Reference in New Issue
Block a user