Implemented SigV4A (#40)

* Implemented should_sign_header callback

* Added SigV4A to SigningAlgorithm

* Added SigV4A test

* Added debugging info to README

* Fixed memory leak from argument vectors

* Fixed memory leak of stream read buffers

* Added support for callables as option values

* Added should_sign_header support and test

* Fixed ELG type bug exposed by aws-crt-ffi change

* Updated to aws-crt-ffi v0.2.0
This commit is contained in:
Justin Boswell
2021-07-28 12:54:37 -07:00
committed by GitHub
parent 3f77a01fbf
commit 92724b8d51
17 changed files with 361 additions and 132 deletions
+2 -1
View File
@@ -7,4 +7,5 @@ namespace AWS\CRT\Auth;
class SigningAlgorithm {
const SIGv4 = 0;
}
const SIGv4_ASYMMETRIC = 1;
}
+5 -1
View File
@@ -23,7 +23,8 @@ class SigningConfigAWS extends NativeResource {
'signed_body_value' => null,
'signed_body_header_type' => SignedBodyHeaderType::NONE,
'expiration_in_seconds' => 0,
'date' => time()
'date' => time(),
'should_sign_header' => null,
];
}
@@ -57,6 +58,9 @@ class SigningConfigAWS extends NativeResource {
self::$crt->signing_config_aws_set_expiration_in_seconds(
$sc, $options->expiration_in_seconds->asInt());
self::$crt->signing_config_aws_set_date($sc, $options->date->asInt());
if ($should_sign_header = $options->should_sign_header->asCallable()) {
self::$crt->signing_config_aws_set_should_sign_header_fn($sc, $should_sign_header);
}
}
function __destruct()
+4
View File
@@ -317,6 +317,10 @@ final class CRT {
self::$impl->aws_crt_signing_config_aws_set_date($signing_config, $timestamp);
}
function signing_config_aws_set_should_sign_header_fn($signing_config, $should_sign_header_fn) {
self::$impl->aws_crt_signing_config_aws_set_should_sign_header_fn($signing_config, $should_sign_header_fn);
}
function signable_new_from_http_request($http_message) {
return self::$impl->aws_crt_signable_new_from_http_request($http_message);
}
+4
View File
@@ -34,6 +34,10 @@ final class OptionValue {
public function asArray() {
return is_array($this->value) ? $this->value : (!empty($this->value) ? [$this->value] : []);
}
public function asCallable() {
return is_callable($this->value) ? $this->value : null;
}
}
final class Options {