Anahita Project

Anahita Project's Topics

Scott Crawford

Scott Crawford

July 23 2019

Revising Anahita's S3 Storage Plugin

Starting a topic on the S3 storage plugin to document the upgrades that appear to be required.  I'll use the topic itself to post relevant background and then post questions I have at the moment as comments on the topic.

Here is an AWS source document I've found describing recent changes:

Key points:

Previous method was referred to as Signature Version 2, the new method is referred to as Signature Version 4.

The original s3lib.php file includes a link in the header comments that is no longer functional.  In researching an updated version of the file, I've found two sources on GitHub:


According to an article I found on Medium, the fork maintained by Rack Lin is preferable:

So I'm using the Rack Lin fork as the starting point for the updates.  Copying down the library file ('S3.php') I found a few extra spaces which once deleted helps focus strictly on what's changed by running a diff against Anahita's 's3lib.php' file.

What's new - variables:

  • $region
  • $progressFunction
  • $signVer

What's new - functions:

  • setRegion()
  • getRegion()
  • setSignatureVersion()
  • setProgressFunction()
  • __getSignatureV4()

What changed - functions:

  • __construct() now includes $region
  • putBucket() now calls getRegion()
  • inputFile() now includes sha256sum encoding
  • putObject() now includes sha256sum encoding
  • __getCloudFrontDistributionConfigXML() now checks that $trustedSigners is not empty
  • getResponse() now checks $signVer for 'v2' versus 'v4'
  • getResponse() now includes the $progressFunction

Anahita's PlgStorageS3 class:

A little intro on Anahita's PlgStorageS3 class, then the questions to follow...

So Anahita's PlgStorageS3 class appears to need revisions in order to account for the signature version and region.  It seems these should be parameters that can be assigned in the Plugin's settings through additions to the s3.json file, with the signature version as a drop-down selector, and the region a text field with the default value of 'us-east-1'.

The "core" functions in PlgStorageS3 (_read, _write, _exists, and _delete) appear they should be compatible with the Rack Lin replacement for the s3lib.php file.

Protected variables would need to be added for $_region and $_signature, and it appears the __construct function would need to be amended to account for both.

Rastin Mehr
Rastin Mehr
September 16 2019 Permalink
Thank you; this is excellent feedback. I think I know what's causing the enabled=0 issue. We've improved the domain entity validations and person signup workflow, but looks like the enabled field for the first signup has been left out. Also, the s3 folder store could be a parameter issue. I'll check it out.
Unknown Person liked this
Rastin Mehr
Rastin Mehr
September 24 2019 Permalink
@scott the issues with person signup and s3 folder should be resolved now. Could you please do another test and let me know if your installation is working as expected? I appreciate it.

Powered by Anahita