kitar/laravel-dynamodb

Host' or ':authority' must be a 'SignedHeader' in the AWS Authorization.

Closed this issue · 10 comments

Hey Guys,

i am a newby at Laravel + DynomoDB.
I followed what is in the readme file. unfortunately I get the following error. What's the problem here?

Aws\DynamoDb\Exception\DynamoDbException

Error executing "Scan" on "dynamodb.eu-central-1.amazonaws.com"; AWS HTTP error: Client error: POST dynamodb.eu-central-1.amazonaws.com resulted in a 400 Bad Request response:
{"__type":"com.amazon.coral.service#InvalidSignatureException","message":"'Host' or ':authority' must be a 'SignedHeader (truncated...)
InvalidSignatureException (client): 'Host' or ':authority' must be a 'SignedHeader' in the AWS Authorization. - {"__type":"com.amazon.coral.service#InvalidSignatureException","message":"'Host' or ':authority' must be a 'SignedHeader' in the AWS Authorization."}

Did you fix this one? I am having the same issue

kitar commented

@n1cklarosa I can't reproduce myself but would like to do some research. According to your package.lock file, what versions for aws/aws-sdk-php and kitar/larvel-dynamodb are installed? Also, let me know what PHP version your app running on.

webpn commented

I have the same issue. These are the versions of the packages I have on the package.lock file:

  • aws/aws-sdk-php version: 3.222.6
  • kitar/laravel-dynamodb version: v1.0.0

Thanks!

kitar commented

@webpn Sorry for the late response. There might be some missing env variables or IAM configs, but I can't reproduce the exact same error.

Can you try to see what happens when you query via more lower level? For example:

via DB Driver

$res = \Illuminate\Support\Facades\DB::table('your-table-name')->scan();

via Connection

$connection = new\Kitar\Dynamodb\Connection([
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
]);
$res = $connection->table('your-table-name')->scan();

via AWS SDK

$client = (new \Aws\Sdk([
    'version' => 'latest',
    'region' => env('AWS_DEFAULT_REGION'),
    'credentials' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
    ]
]))->createDynamoDb();

$res = $client->scan(['TableName' => 'your-table-name']);

Same issue here.

It works when I query via Connection or directly the AWS SDK, but not from DB Driver.

Any thoughts @kitar? Thank you.

kitar commented

@lucasgiovanny Thanks for reporting! It looks like I should re-open this issue. However, I'm still having trouble reproducing it.

If possible, can I look into your whole application code that can reproduce this issue? (Of course, it does not have to be your actual project code)

@kitar It's a fresh Laravel installation just for testing the package.

But, looks like the problem is when you set the DYNAMODB_ENDPOINT.
If you set the address on .env, the drive doesn't work and throw this error. If I remove this from .env it works.

The address is correct.

kitar commented

@lucasgiovanny Thanks for debugging! Can you see what happens if you add a protocol to your DYNAMODB_ENDPOINT? (eg. https://dynamodb.us-east-1.amazonaws.com)

If it works, we could consider adding a default protocol if not specified.

@kitar Correct! The end point needs to have a protocol to work.

I just opened a PR to fix this matter. Thanks.

kitar commented

@lucasgiovanny Good to hear, and thanks for the PR! I'll merge it soon :)