In all AWS Cognito SDKs in most functions you can pass an UserContextData
parameter to feed Cognito's Advanced Security feature:
$result = $client->forgotPassword([
'AnalyticsMetadata' => [
'AnalyticsEndpointId' => '<string>',
],
'ClientId' => '<string>', // REQUIRED
'SecretHash' => '<string>',
'UserContextData' => [ // <=================== THIS
'EncodedData' => '<string>',
],
'Username' => '<string>', // REQUIRED
]);
This field expects some EncodedData
.
What should I put in UserContextData
and how do I "encode" it?
When using an Admin*
function like AdminInitiateAuth
I can send unencoded fingerprinting data through ContextData
:
$result = $client->adminInitiateAuth([
[...]
'ContextData' => [
'EncodedData' => '<string>',
'HttpHeaders' => [ // REQUIRED
[
'headerName' => '<string>',
'headerValue' => '<string>',
],
// ...
],
'IpAddress' => '<string>', // REQUIRED
'ServerName' => '<string>', // REQUIRED
'ServerPath' => '<string>', // REQUIRED
],
[...]
]);
The documentation does not help:
Amazon Cognito can automatically verify email addresses or phone numbers. To do this verification, Amazon Cognito sends a verification code or a verification link. For email addresses, Amazon Cognito can send a code or a link in an email message. For phone numbers, Amazon Cognito sends a code in an SMS text message.
SRP_A is basically a large integer generated client side. For example in Java you can do: a = new BigInteger(EPHEMERAL_KEY_LENGTH, SECURE_RANDOM).mod(N); A = g.modPow(a, N); github.com/aws/aws-sdk-android/blob/master/… Where N is a big prime.
ClientMetadata. A map of custom key-value pairs that you can provide as input for certain custom workflows that this action triggers. You create custom workflows by assigning AWS Lambda functions to user pool triggers.
AWS provides an opaque implementation for user context data.
encodedData
is to be collected on device and not the server.
The Cognito Javascript client SDK exposes a method to achieve this. It is provided for in the Amplify Android SDK
You can get transfer encodedData
from client to server, then forward that in your request to Cognito.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With