2016-08-01 12 views
2

は、私たちは、任意の関数を使用してパスワードを保存retireve:SecRequestSharedWebCredential資格情報に「パスワードが保存されていません」が含まれていますか?

SecRequestSharedWebCredential(NULL, NULL, ^(CFArrayRef credentials, CFErrorRef error) { 
    if (!error && CFArrayGetCount(credentials)) { 
     CFDictionaryRef credential = CFArrayGetValueAtIndex(credentials, 0); 
     if (credential > 0) { 
      CFDictionaryRef credential = CFArrayGetValueAtIndex(credentials, 0); 
      NSString *username = CFDictionaryGetValue(credential, kSecAttrAccount); 
      NSString *password = CFDictionaryGetValue(credential, kSecSharedPassword); 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       //Updates the UI here. 
      }); 
     } 
    } 
}); 

問題は、IOS 9.3.3 iPhone 6 A1524に、私たちは「パスワードが保存されていない」と呼ばれるエントリとプロンプトを取得することです。パスワードが見つからないことを示すエラーメッセージはありません。配列> 0なので、エントリを持つフォームを完成させます。

これはなぜですか?権限のあるドメインにパスワードが格納されていないと、prmoptが表示されないと考えました。

提案がありますか?

ありがとうございます。

答えて

1

これは私の認証ビューコントローラのviewDidLoad()で確認しています。コードは上記とは少し異なり、他のいくつかのSO答えから集められています。

スウィフト3:

SecRequestSharedWebCredential(Configuration.webBaseFQDN as CFString, nil, { (credentials, error) in 

    if let error = error { 
     print("ERROR: credentials") 
     print(error) 
    } 

    guard let credentials = credentials, CFArrayGetCount(credentials) > 0 else { 
     // Did not find a shared web credential. 
     return 
    } 

    guard CFArrayGetCount(credentials) == 1 else { 
     // There should be exactly one credential. 
     return 
    } 

    let unsafeCredential = CFArrayGetValueAtIndex(credentials, 0) 
    let credential = unsafeBitCast(unsafeCredential, to: CFDictionary.self) 

    let unsafeEmail = CFDictionaryGetValue(credential, Unmanaged.passUnretained(kSecAttrAccount).toOpaque()) 
    let email = unsafeBitCast(unsafeEmail, to: CFString.self) as String 

    let unsafePassword = CFDictionaryGetValue(credential, Unmanaged.passUnretained(kSecSharedPassword).toOpaque()) 
    let password = unsafeBitCast(unsafePassword, to: CFString.self) as String 

    if self.isValidEmail(email) && self.isValidPassword(password) { 
     self.usedSharedWebCredentials = true 
     self.doSignIn(email: email, password: password) 
    } 
}) 

isValidEmail(_:)isValidPassword(_:)のための最後に余分なチェックがSecRequeestSharedWebCredential()戻って最初の資格(電子メール)に「パスワードが保存されていない」場合を扱います。

誰かがこれがどうして起こっているのかを説明してもらいたいと思いますが、そうでない場合は、少なくともこのシナリオを捉える方法があります。

これをiOS 10.2.1まで見てきました。

関連する問題