kitar / laravel-dynamodb

A DynamoDB based Eloquent model and Query builder for Laravel.
MIT License
179 stars 27 forks source link

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

Closed wwwDESIGN-basti closed 1 year ago

wwwDESIGN-basti commented 2 years ago

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."}

n1cklarosa commented 2 years ago

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

kitar commented 2 years ago

@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 2 years ago

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

Thanks!

kitar commented 2 years ago

@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']);
lucasgiovanny commented 2 years ago

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 1 year ago

@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)

lucasgiovanny commented 1 year ago

@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 1 year ago

@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.

lucasgiovanny commented 1 year ago

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

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

kitar commented 1 year ago

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