-
Notifications
You must be signed in to change notification settings - Fork 13
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
Implemented async callbacks to PHP regardless of thread model, Sigv4 signing #24
Conversation
…http message signing
…#25) * Broke C code into separate files, moved common stuff to php_aws_crt.h * clang-format * Use a unity build to make PHP do the right thing with our lib
tests/SigningTest.php
Outdated
]); | ||
$http_request = new Request('GET', '/', [], ['Host' => 'example.amazonaws.com']); | ||
$this->assertNotNull($http_request, "Unable to create HttpRequest for signing"); | ||
$signable = Signable::fromHttpRequest($http_request); | ||
$this->assertNotNull($signable, "Unable to create signable from HttpRequest"); | ||
|
||
Signing::signRequestAws($signable, $signing_config, function() { | ||
|
||
Signing::signRequestAws($signable, $signing_config, function($signing_result, $error_code) use (&$http_request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like more than 80 characters and if it is should be split into more lines
tests/SigningTest.php
Outdated
}); | ||
|
||
$headers = $http_request->headers(); | ||
$this->assertEquals('AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31', $headers->get('Authorization')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to shrink this, I would have to heredoc it, and then strip newlines from it. That seems a bit counter to simplicity, eh?
Please add a method to expose the following line: This will reduce code duplication and enable us to throw an error when the extension isn't loaded and a feature requires sigv4a |
See |
@@ -23,6 +23,7 @@ public static function defaults() { | |||
'signed_body_value' => null, | |||
'signed_body_header_type' => SignedBodyHeaderType::NONE, | |||
'expiration_in_seconds' => 0, | |||
'date' => time() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a unix date, it could be named unixDate or something depending on how it is used to make it clear it has the exact timestamp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so while it is a timestamp, it will be quantized to the year/month/day, so it is a date. In the SigV4 docs:
Note that the date used in the hashing process is in the format YYYYMMDD (for example, 20150830), and does not include the time.
@@ -34,7 +35,9 @@ public function __construct(array $options = []) { | |||
$sc = $this->acquire(self::$crt->signing_config_aws_new()); | |||
self::$crt->signing_config_aws_set_algorithm($sc, $options->algorithm->asInt()); | |||
self::$crt->signing_config_aws_set_signature_type($sc, $options->signature_type->asInt()); | |||
self::$crt->signing_config_aws_set_credentials_provider($sc, $options->credentials_provider->asObject()); | |||
if ($credentials_provider = $options->credentials_provider->asObject()) { | |||
self::$crt->signing_config_aws_set_credentials_provider($sc, $credentials_provider->native); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
92 characters so it should be split among a few lines:
self::$crt->signing_config_aws_set_credentials_provider(\n \t$sc,\n \t$credentials_provider->native\n );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pick a linter. This is going to kill me. This is what tools are for :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it anyway
src/AWS/CRT/Auth/SigningResult.php
Outdated
} | ||
|
||
function __destruct() { | ||
// No release necessary, SigningResults are transient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this comment here? And if it's not necessary, why do you do it on the next line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, this was indeed confusing as hell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope you don't mind if I just run the whole thing through a PHP linter at some point in the future. Figure it'll be easier that way
I will be overjoyed! Then tell me what it is so I can use it to verify! |
* Added CI runs for all versions of PHP * PHP >= 7.1 is required for arginfo generation * Allow PHP 5.5 to compile * Added extension API detection for every minor version we support * Pinned version of phpunit for ancient php 5.5 * Added special php 5.5 CI * Updated to builder v0.8.18 * Added shim for expectException
Depends on:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.