urbit / landscape

Product board for Landscape.
20 stars 6 forks source link

S3 - Invalid authorization header - wrong region when uploading profile image #1502

Open chadmyers opened 1 year ago

chadmyers commented 1 year ago

I am using the Remote Storage option and have configured an AWS S3 bucket in us-west-2 (Oregon) region. I have set up the endpoint for s3-us-west-2.amazonaws.com. I think I have my S3 bucket and CORS set up properly (since I got a different error when I didn't CORS set up and then I re-read the docs and set it up properly).

When I attempt to upload a profile photo, I get a 200 on the pre-flight check (OPTIONS) but a 400 (Bad Request) error on the attempt to PUT to https://MYBUCKETNAME.s3-us-west-2.amazonaws.com/MYPLANET/2022.11.03..22.55.24-profileimg.jpg

The response body is (formatted for your convenience):

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>AuthorizationHeaderMalformed</Code>
  <Message>The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-west-2'</Message>
  <Region>us-west-2</Region>
  <RequestId>REDACTED</RequestId>
  <HostId>9R+JQSful8AwLA4ys0Xo1hK7iGWgHfXXXks0avFzAOvDrlngITkf2rDpm01NQv4X7lMquM3yp5A=</HostId>
</Error>

The Authorization header on the request is:

Authorization: AWS4-HMAC-SHA256 Credential=REDACTED/20221103/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-acl;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=REDACTED

Note the us-east-1 in the Credential=.

chadmyers commented 1 year ago

I'm going to try to make a bucket in us-east-1 and see if that works and report back.

chadmyers commented 1 year ago

NOTE: If I can get all this working, I am willing to assist in adding AWS-specific information to the Remote Storage config page docs for configuring AWS S3 storage.