Files
passforios-mirror/passAutoFillExtension/Controllers/PasscodeExtensionDisplay.swift
Allan Feldman 83c6ae33dc Fix security bug which autofilled passwords without passcode/faceid auth
The autofill extension currently calls the success callback even if a
passcode/FaceID is not successfully verified.

In the case that the PGP key passphrase is stored, this results in
password decryption without further user interaction.

The fix is to only decrypt passwords upon successful passcode / FaceID
verification.
2023-03-09 12:55:39 -08:00

31 lines
1014 B
Swift

//
// PasscodeExtensionDisplay.swift
// passAutoFillExtension
//
// Created by Yishi Lin on 14/6/17.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import passKit
class PasscodeExtensionDisplay {
private let passcodeLockVC: PasscodeLockViewControllerForExtension
init(extensionContext: NSExtensionContext) {
self.passcodeLockVC = PasscodeLockViewControllerForExtension(extensionContext: extensionContext)
passcodeLockVC.setCancellable(true)
}
// present the passcode lock view if passcode is set and the view controller is not presented
func presentPasscodeLockIfNeeded(_ sender: UIViewController, before: (() -> Void)? = nil, after: (() -> Void)? = nil) {
if PasscodeLock.shared.hasPasscode {
before?()
passcodeLockVC.successCallback = after
passcodeLockVC.modalPresentationStyle = .fullScreen
sender.parent?.present(passcodeLockVC, animated: false)
} else {
after?()
}
}
}