I am trying to use AuthFlow USER_SRP_AUTH
for user login. I am getting the "PASSWORD_VERIFIER" challenge in the response of initiateAuth request. While responding to that challenge I am not sure what I should pass as the value of PASSWORD_CLAIM_SIGNATURE
. I have tried different values as per documentation and java code but no success.
I'm using the code below for the respondToAuthChallenge
method:
$date = date('D M d H:i:s T Y');
$srp = new Srp();
$a = $srp->getRandomSeed();
$A = $srp->generateA($a);
$challengeParameters = $result->get('ChallengeParameters');
$s = $srp->getRandomSeed();
$x = $srp->generateX($s, 'MY_USERNAME', 'MY_PASSWORD');
$S = $srp->generateS_Client($A, $challengeParameters['SRP_B'], $a, $x);
$K = $srp->generateK($S);
$response = $client->respondToAuthChallenge([
'ChallengeName' => 'PASSWORD_VERIFIER',
'ClientId' => 'CLIENT_ID',
'ChallengeResponses' => [
'TIMESTAMP' => $date,
'USERNAME' => $challengeParameters['USER_ID_FOR_SRP'],
'PASSWORD_CLAIM_SECRET_BLOCK' => $challengeParameters['SECRET_BLOCK'],
'PASSWORD_CLAIM_SIGNATURE' => hash_hmac('sha256', $K, $challengeParameters['SALT'])
]
]);
I have used this PHP SRP Client: https://github.com/falkmueller/srp/
In the response of respondToAuthChallenge
request, I am getting this error
400 Bad Request` response:
{"__type":"NotAuthorizedException","message":"Incorrect username or password."}
Most likely this error caused by an incorrect PASSWORD_CLAIM_SIGNATURE
. Since I haven't really found what this key should contain as a value and just tried some things based on documentation and java code I've found.