Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK working with master credentials but not with IAM #524

Closed
cizal opened this issue Mar 30, 2015 · 2 comments
Closed

SDK working with master credentials but not with IAM #524

cizal opened this issue Mar 30, 2015 · 2 comments

Comments

@cizal
Copy link

cizal commented Mar 30, 2015

Maybe this is not something that I need to report as an issue, but I went through the documentation and online resources and wasn't able to find anything that would make this work.
When using the master key/secret everything works. However, when using the IAM key/secret I constantly receive

AWS Error Code: SignatureDoesNotMatch, Status Code: 403, AWS Request ID: 4753C8291E073CE9, AWS Error Type: client, AWS Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Here is my IAM policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1427650841800",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::BUCKETNAME/*"
    }
  ]
}

This is the bucket policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1427647391802",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::AWS_ACOUNT_ID:user/IAM_USERNAME"
            },
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::BUCKETNAME/*"
        }
    ]
}

I even removed the policies so that the user can have full permissions on all of the buckets but I still receive the same error.

Here is a sample request/response:

# Request:
PUT /testfile.txt HTTP/1.1
Host: esquireprod.s3-us-west-2.amazonaws.com
x-amz-acl: public-read
Content-Type: text/plain
Content-MD5: 2UY2sCtfw4i/iNjVn28myA==
User-Agent: aws-sdk-php2/2.7.24 Guzzle/3.9.3 curl/7.22.0 PHP/5.5.20-1+deb.sury.org~precise+1 Laravel/4.2.17 L4MOD/1.1.0
Date: Mon, 30 Mar 2015 00:31:31 +0000
Authorization: AWS AKIAIM43ZC4YWNBD6S6A:m6uzQ+odmuKmtE8D8TIbKI3LNQE=
Content-Length: 32

Some test content in the file...

# Response:
HTTP/1.1 403 Forbidden
x-amz-request-id: 87AA985EC92E6EB0
x-amz-id-2: pYVZpGy10y52KmNewF4sSZYDkB5Uem8GNx1qRee/gwF2TqVcL131i9yDaa/2VSEsV/GfgfOGRys=
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Mon, 30 Mar 2015 00:31:31 GMT
Connection: close
Server: AmazonS3

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAIM43ZC4YWNBD6S6A</AWSAccessKeyId><StringToSign>PUT
2UY2sCtfw4i/iNjVn28myA==
text/plain
Mon, 30 Mar 2015 00:31:31 +0000
x-amz-acl:public-read
/esquireprod/testfile.txt</StringToSign><SignatureProvided>m6uzQ+odmuKmtE8D8TIbKI3LNQE=</SignatureProvided><StringToSignBytes>50 55 54 0a 32 55 59 32 73 43 74 66 77 34 69 2f 69 4e 6a 56 6e 32 38 6d 79 41 3d 3d 0a 74 65 78 74 2f 70 6c 61 69 6e 0a 4d 6f 6e 2c 20 33 30 20 4d 61 72 20 32 30 31 35 20 30 30 3a 33 31 3a 33 31 20 2b 30 30 30 30 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 75 62 6c 69 63 2d 72 65 61 64 0a 2f 65 73 71 75 69 72 65 70 72 6f 64 2f 74 65 73 74 66 69 6c 65 2e 74 78 74</StringToSignBytes><RequestId>87AA985EC92E6EB0</RequestId><HostId>pYVZpGy10y52KmNewF4sSZYDkB5Uem8GNx1qRee/gwF2TqVcL131i9yDaa/2VSEsV/GfgfOGRys=</HostId></Error>```

I'm using the AWS Service Provider for Laravel 4, here is the sample code(basic putObject call):
```php
$s3 = AWS::get('s3');
$file = public_path('assets/original/testfile.txt');
$s3->addSubscriber(\Guzzle\Plugin\Log\LogPlugin::getDebugPlugin());
$result = $s3->putObject(array(
               'Bucket'     => 'esquireprod',
               'Key'        => 'testfile.txt',
               'SourceFile' => $file,
               'ACL'    => 'public-read'
               ));
@cizal
Copy link
Author

cizal commented Mar 30, 2015

After further research I located the problem to the AWS Service Provider for Laravel 4 and opened the issue there: aws/aws-sdk-php-laravel#66.

@jeremeamia
Copy link
Contributor

I'll address it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants