aws / aws-iot-device-sdk-js-v2

Next generation AWS IoT Client SDK for Node.js using the AWS Common Runtime
Apache License 2.0
213 stars 96 forks source link

Policy for /browser/custom_authorizer_connect sample project is missing details #501

Open jhonangelmireles opened 1 month ago

jhonangelmireles commented 1 month ago

Describe the issue

The websocket connection will fail unless the Lambda function return the following policy:

{
  "isAuthenticated": true,
  "principalId": "TEST123",
  "policyDocuments": [
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Action": ["iot:Connect"],
          "Effect": "Allow",
          "Resource": [
            "arn:aws:iot:us-east-1:123456789012:client/custom_authorizer_connect_sample*"
          ]
        },
        {
          "Action": ["iot:Publish"],
          "Effect": "Allow",
          "Resource": ["arn:aws:iot:us-east-1:123456789012:topic/test/topic"]
        },
        {
          "Action": ["iot:Subscribe"],
          "Effect": "Allow",
          "Resource": [
            "arn:aws:iot:us-east-1:123456789012:topicfilter/test/topic"
          ]
        },
        {
          "Action": ["iot:Receive"],
          "Effect": "Allow",
          "Resource": ["arn:aws:iot:us-east-1:578079176758:topic/test/topic"]
        }
      ]
    }
  ],
  "disconnectAfterInSeconds": 3600,
  "refreshAfterInSeconds": 300
}

Links

https://github.com/aws/aws-iot-device-sdk-js-v2/tree/main/samples/browser/custom_authorizer_connect

jmklix commented 1 month ago

Thanks for pointing out this error in our docs. I've made a PR to fix this.