How to Add AWS v4 signature on s3 (FuelPHP package)

Lemon Kazi
Oceanize Lab Geeks
Published in
2 min readMay 2, 2019

Few days ago I got a notification from my client that “ S3 will change Signature version. signature 2 will be deprecated

So I was afraid that it may effect our s3 upload process. So I tried to solve that problem and today I will share that how I solved my problem. Hope it will help others also

Note: If you already using the official Amazon SDK then no need to do below process just composer update will solve your problem.

Actually my previous process built with signature version 2 so I updated that into signature version 4.

Steps I followed:

  1. My previous package I used from below link. https://github.com/danharper/fuel-s3
  2. problem is that they didn’t update their package for long time and due to AWS privacy update I need to change it. So I did some study and updated code in my fuelphp directory

fuel/packages/s3/classes/s3.php

with this

https://gist.github.com/lemonkazi/bd056a8a3b19c149c8a9701abbcc0e73

Here I have added new method __getSignatureV4 and called this method from request.php

actually in this signature version 4 AWS actually checking new algorithm

Using ‘AWS4-HMAC-SHA256’ for authorization.

I used that authorization and passed that through header previously that authorization was not required.

$resultHeaders = array(
‘X-AMZ-DATE’ => $amzDate,
‘Authorization’ => $authorizationStr
);

3. To call that new method with signature version 4 I updated my old code

fuel/packages/s3/classes/s3/request.php

with below

https://gist.github.com/lemonkazi/9b2de665739e1fd09c4c7d99fca07031

If you want to know more about fuel-s3 package visit below link

https://github.com/danharper/fuel-s3

--

--