gpt4 book ai didi

security - Sirikit : Touch Id and increasing security

转载 作者:行者123 更新时间:2023-12-05 00:55:15 27 4
gpt4 key购买 nike

试图让我的头脑在下面:

  • https://developer.apple.com/videos/play/wwdc2016/225/
    提到 sendPayments 意图默认是 IntentsRestrictedWhileLocked,但是如果我们想提高安全性以便用户需要使用 Touch Id(本地身份验证)进行批准,那么这将如何完成?这在设备被锁定/解锁时都需要。我假设扩展需要在“确认”阶段以某种方式显示本地身份验证 UI?
  • 他们还提到可以增加安全性,但只需要确认执行它的机制是否只是 IntentsRestrictedWhileLocked 扩展属性?或者有没有办法指定需要touch id身份验证?
  • 最佳答案

    要回答这两个问题,是的,您可以使用 Touch ID 提高支付的安全性,这是我在 Apple 的示例代码 here 上实现它的方法,我在 SendPaymentIntentHandler.swift 中添加了以下函数:

    func authenticate(successAuth: @escaping () -> Void, failure: @escaping (NSError?) -> Void) {
    // 1. Create a authentication context
    let authenticationContext = LAContext()
    var error:NSError?
    guard authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
    failure(error)
    return
    }
    // 3. Check the fingerprint
    authenticationContext.evaluatePolicy(
    .deviceOwnerAuthenticationWithBiometrics,
    localizedReason: "Unlock to send the money",
    reply: { [unowned self] (success, error) -> Void in

    if( success ) {
    successAuth()

    }else {
    let message = self.errorMessageForLAErrorCode(errorCode: (error! as NSError).code)
    print(message)
    failure(error! as NSError)
    }

    })

    }

    func errorMessageForLAErrorCode( errorCode:Int ) -> String{

    var message = ""

    switch errorCode {

    case LAError.appCancel.rawValue:
    message = "Authentication was cancelled by application"

    case LAError.authenticationFailed.rawValue:
    message = "The user failed to provide valid credentials"

    case LAError.invalidContext.rawValue:
    message = "The context is invalid"

    case LAError.passcodeNotSet.rawValue:
    message = "Passcode is not set on the device"

    case LAError.systemCancel.rawValue:
    message = "Authentication was cancelled by the system"

    case LAError.touchIDLockout.rawValue:
    message = "Too many failed attempts."

    case LAError.touchIDNotAvailable.rawValue:
    message = "TouchID is not available on the device"

    case LAError.userCancel.rawValue:
    message = "The user did cancel"

    case LAError.userFallback.rawValue:
    message = "The user chose to use the fallback"

    default:
    message = "Did not find error code on LAError object"

    }

    return message

    }

    然后在handle方法中调用函数authenticate,结果是我的app在确认支付后要求进行Touch ID认证,然后在用户认证了自己之后就成功发送了支付。

    关于security - Sirikit : Touch Id and increasing security,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38428121/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com