用自定义流放大ios签名



我正在尝试使用amplify-ios库和cognito实现一个自定义签名流。流基于此无密码实现https://github.com/mobilequickie/amplify-passwordless-sms-auth/tree/68152489152e1fc4c3185f4e5e3383639bdc8285,它在网络上运行得很好,但我无法使它在ios上运行,我得到以下错误:

-------Sign In response---------
failure(AuthError: Incorrect username or password.
Recovery suggestion: Check whether the given values are correct and the user is authorized to perform the operation.)

请在下面找到相关代码:

public init(_ secureService: SecureServiceProtocol) {
self.secureService = secureService
self.token = secureService.get(tokenKey)
self.authModel = secureService.get(authKey, type: AuthModel.self)

do {
let url = Bundle.main.url(forResource: "amplifyconfiguration", withExtension: "json")!
let configuration = try AmplifyConfiguration(configurationFile: url)
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure(configuration)
if authModel != nil {
self.retrieveAuthData { _ in }
}
} catch {
L.log(type: .error, message: error.localizedDescription)
print(error)
print(error.asAFError)
}
}
public func accessWith(_ phone: String, callback: @escaping AuthResultCallback) {     
print(phone)
Amplify.Auth.signIn(username: phone) { result in
print("-------Sign In response---------")
print(result)
}
}

配置

{
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {}
}
},
"CognitoUserPool": {
"Default": {
"Region": "eu-west-2",
"PoolId": "eu-west-2xxxxxx",
"AppClientId": "5vmjioxxxxxxxxxx"
}
}
},
"Auth": {
"Default": {
"authenticationFlowType": "CUSTOM_AUTH"
}
}
}
}
}

我一直面临同样的问题,并发现了这个

我们问题的根本原因是iOS Amplify库总是向CognitosignIn调用发送SRP_A的初始ChallengeName。然而,示例";定义Auth质询触发器";被明确编码为在ChallengeName不是CCD_ 3的情况下使任何身份验证调用失败。

所以你需要用这些Lambda移植同样的行为。由于Define lambda查找CUSTOM_CHALLENGEChallengeName,并使具有不同ChallngeName的请求失败,因此该逻辑与iOS Amplify库不兼容,因为它们最初发送SRP_A

我可以通过修改Define Auth Challengelambda来响应CUSTOM_CHALLENGE名称,而不是直接失败来解决这个问题,这似乎已经解决了iOS方面的问题。

你可以在这里使用lambda

最新更新