我应该使用什么作为Cognito的UserContextData => EncodedData?

时间:2019-10-01 14:07:00

标签: php amazon-web-services amazon-cognito

在大多数功能的所有AWS Cognito SDK中,您可以传递一个UserContextData参数来提供Cognito的Advanced Security功能:

$result = $client->forgotPassword([
  'AnalyticsMetadata' => [
    'AnalyticsEndpointId' => '<string>',
  ],
  'ClientId' => '<string>', // REQUIRED
  'SecretHash' => '<string>',
  'UserContextData' => [  // <=================== THIS
    'EncodedData' => '<string>',
  ],
  'Username' => '<string>', // REQUIRED
]);  

此字段需要一些EncodedData

我应该在UserContextData中输入什么内容,如何对其进行“编码”?

使用像Admin*这样的AdminInitiateAuth函数时,我可以通过ContextData发送未编码的指纹数据:

$result = $client->adminInitiateAuth([
    [...]
    'ContextData' => [
        'EncodedData' => '<string>',
        'HttpHeaders' => [ // REQUIRED
            [
                'headerName' => '<string>',
                'headerValue' => '<string>',
            ],
            // ...
        ],
        'IpAddress' => '<string>', // REQUIRED
        'ServerName' => '<string>', // REQUIRED
        'ServerPath' => '<string>', // REQUIRED
    ],
    [...]
]);

documentation无济于事:
enter image description here

1 个答案:

答案 0 :(得分:2)

AWS为用户上下文数据提供了https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services

encodedData将在设备而不是服务器上收集。

Cognito opaque implementation公开了一种实现此目的的方法。它在Javascript client SDK

中提供

您可以将encodedData从客户端转移到服务器,然后将其转发给Cognito。