2017 © Pedro Peláez
 

library aws-post-v4-sign

Create a signature for Amazon S3 POST API request

image

mfn/aws-post-v4-sign

Create a signature for Amazon S3 POST API request

  • Friday, January 29, 2016
  • by mfn
  • Repository
  • 2 Watchers
  • 5 Stars
  • 728 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

THIS REPO IS ARCHIVED

Please use the features of the official AWS SDK PHP https://github.com/aws/aws-sdk-php, (*1)

Specifically, have a look at https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-post.html, (*2)


Create V4 signature for AWS S3 REST API Post requests Travis Build Status

Homepage: https://github.com/mfn/php-aws-post-v4-sign, (*3)

Blurb

This library can create signature for a POST request designated for Amazon Simple Storage (S3) REST API service., (*4)

This package does not depend on the AWS PHP SDK. It can only create a signature. Logically, this code exists in similar form inside the SDK, but it's not possible form the outside to leaverage it., (*5)

Fore more information see: - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingHTTPPOST.html - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html, (*6)

Requirements

PHP 5.4, (*7)

Install / Setup

Using composer: composer.phar require mfn/aws-post-v4-sign 0.1, (*8)

Example

<?php
use Mfn\Aws\Signature\V4\SignatureV4;

$secret = 'ADFSDFDS3432S23423'; # Your secret key => never share!
$time = time();
$credential = join('/', [
    $accesKeyId, # Your AWS access key ID
    gmdate('Ymd', $time),
    'us-west-1',
    's3',
    'aws4_request',
]);
# Example policy
$policy = [
    'expiration' => gmdate('Y-m-d\TH:i:s\Z', strtotime('+2 hours', $time)),
    'conditions' => [
        ['acl' => 'public-read'],
        ['bucket' => 'your-bucket'],
        ['starts-with', '$key', ''],
        ['x-amz-credential' => $credential],
        ['x-amz-algorithm' => 'AWS4-HMAC-SHA256'],
        ['x-amz-date' => gmdate('Ymd\THis\Z', $time)],
    ],
];

$sigGen = new SignatureV4(
    $secret, # the secret part; never share with anyone!
    $policy
);
$signature = $sigGen->getSignature();

The SignatureV4 class will parse the $policy to that extent to extract the x-awz-credential key, as this credential is an essential part for creating the signature., (*9)

As a base64 encoded JSON representation of the $policy is required to create the signature and is usually required for the final request, a method for retrieving it exists: $encodedPolicy = $sigGen->getBase64EncodedPolicy();, (*10)

Contribute

Fork it, hack on a feature branch, create a pull request, be awesome!, (*11)

No developer is an island so adhere to these standards:, (*12)

© Markus Fischer markus@fischer.name, (*13)

The Versions

29/01 2016

dev-master

9999999-dev http://github.com/mfn/php-aws-post-v4-sign

Create a signature for Amazon S3 POST API request

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Markus Fischer

api s3 aws post

29/01 2016

0.1

0.1.0.0 http://github.com/mfn/php-aws-post-v4-sign

Create a signature for Amazon S3 POST API request

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Markus Fischer

api s3 aws post