Request Attribution (#59)

This commit is contained in:
Max Goedjen
2020-03-17 00:56:55 -07:00
committed by GitHub
parent 4b66e874a7
commit 2b5fdf541d
7 changed files with 95 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}()
let notifier = Notifier()
lazy var agent: Agent = {
Agent(storeList: storeList/*, notifier: notifier*/)
Agent(storeList: storeList, witness: notifier)
}()
lazy var socketController: SocketController = {
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String

View File

@@ -11,11 +11,11 @@ class Notifier {
}
}
func notify(accessTo secret: AnySecret) {
func notify(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) {
let notificationCenter = UNUserNotificationCenter.current()
let notificationContent = UNMutableNotificationContent()
notificationContent.title = "Signed Request"
notificationContent.body = "\(secret.name) was used to sign a request."
notificationContent.body = "\(secret.name) was used to sign a request from \(provenance.origin.name)."
let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil)
notificationCenter.add(request, withCompletionHandler: nil)
}
@@ -24,8 +24,8 @@ class Notifier {
extension Notifier: SigningWitness {
func witness(accessTo secret: AnySecret) throws {
notify(accessTo: secret)
func witness(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws {
notify(accessTo: secret, by: provenance)
}
}