AWS Credentials support, StaticCredentials Provider (#17)

* added credentials API, disabled FFI backend for now

* Added CredentialsTest

* Added support for specifying CMAKE_BUILD_TYPE on the command line

* Added support for AwsCredentials and StaticCredentialsProvider
This commit is contained in:
Justin Boswell
2021-03-17 13:59:05 -04:00
committed by GitHub
parent 9171857448
commit 73ecd3bc8a
16 changed files with 585 additions and 86 deletions
+35 -5
View File
@@ -10,12 +10,42 @@ function aws_crt_error_str(int $error_code): string {}
function aws_crt_error_debug_str(int $error_code): string {}
function aws_crt_event_loop_group_options_new(): object {}
function aws_crt_event_loop_group_options_new(): int {}
function aws_crt_event_loop_group_options_release(object $elg_options): void {}
function aws_crt_event_loop_group_options_release(int $elg_options): void {}
function aws_crt_event_loop_group_options_set_max_threads(object $elg_options, int $max_threads): void {}
function aws_crt_event_loop_group_options_set_max_threads(int $elg_options, int $max_threads): void {}
function aws_crt_event_loop_group_new(object $options): object {}
function aws_crt_event_loop_group_new(int $options): int {}
function aws_crt_event_loop_group_release(object $event_loop_group): void {}
function aws_crt_event_loop_group_release(int $event_loop_group): void {}
function aws_crt_credentials_options_new(): int {}
function aws_crt_credentials_options_release(int $options): void {}
function aws_crt_credentials_options_set_access_key_id(int $options, string $access_key_id): void {}
function aws_crt_credentials_options_set_secret_access_key(int $options, string $secret_access_key): void {}
function aws_crt_credentials_options_set_session_token(int $options, string $session_token): void {}
function aws_crt_credentials_options_set_expiration_timepoint_seconds(int $options, int $expiration_timepoint_seconds): void {}
function aws_crt_credentials_new(int $options): int {}
function aws_crt_credentials_release(int $credentials): void {}
function aws_crt_credentials_provider_release(int $credentials): void {}
function aws_crt_credentials_provider_static_options_new(): int {}
function aws_crt_credentials_provider_static_options_release(int $options): void {}
function aws_crt_credentials_provider_static_options_set_access_key_id(int $options, string $access_key_id): void {}
function aws_crt_credentials_provider_static_options_set_secret_access_key(int $options, string $secret_access_key): void {}
function aws_crt_credentials_provider_static_options_set_session_token(int $options, string $session_token): void {}
function aws_crt_credentials_provider_static_new(int $options): int {}
+83 -8
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: a2ad6edf64d0416356ba2a9a4c8b184615054a7c */
* Stub hash: c681786667e5b7755b2874e4862ea7f162ef61ee */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_last_error, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -12,26 +12,71 @@ ZEND_END_ARG_INFO()
#define arginfo_aws_crt_error_debug_str arginfo_aws_crt_error_name
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_options_new, 0, 0, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
#define arginfo_aws_crt_event_loop_group_options_new arginfo_aws_crt_last_error
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_options_release, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, elg_options, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO(0, elg_options, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_options_set_max_threads, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, elg_options, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO(0, elg_options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, max_threads, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_new, 0, 1, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_OBJECT, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_new, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_event_loop_group_release, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, event_loop_group, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO(0, event_loop_group, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_aws_crt_credentials_options_new arginfo_aws_crt_last_error
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_options_release, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_options_set_access_key_id, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, access_key_id, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_options_set_secret_access_key, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, secret_access_key, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_options_set_session_token, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, session_token, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_options_set_expiration_timepoint_seconds, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, expiration_timepoint_seconds, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_aws_crt_credentials_new arginfo_aws_crt_event_loop_group_new
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_credentials_release, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, credentials, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_aws_crt_credentials_provider_release arginfo_aws_crt_credentials_release
#define arginfo_aws_crt_credentials_provider_static_options_new arginfo_aws_crt_last_error
#define arginfo_aws_crt_credentials_provider_static_options_release arginfo_aws_crt_credentials_options_release
#define arginfo_aws_crt_credentials_provider_static_options_set_access_key_id arginfo_aws_crt_credentials_options_set_access_key_id
#define arginfo_aws_crt_credentials_provider_static_options_set_secret_access_key arginfo_aws_crt_credentials_options_set_secret_access_key
#define arginfo_aws_crt_credentials_provider_static_options_set_session_token arginfo_aws_crt_credentials_options_set_session_token
#define arginfo_aws_crt_credentials_provider_static_new arginfo_aws_crt_event_loop_group_new
ZEND_FUNCTION(aws_crt_last_error);
ZEND_FUNCTION(aws_crt_error_name);
@@ -42,6 +87,21 @@ ZEND_FUNCTION(aws_crt_event_loop_group_options_release);
ZEND_FUNCTION(aws_crt_event_loop_group_options_set_max_threads);
ZEND_FUNCTION(aws_crt_event_loop_group_new);
ZEND_FUNCTION(aws_crt_event_loop_group_release);
ZEND_FUNCTION(aws_crt_credentials_options_new);
ZEND_FUNCTION(aws_crt_credentials_options_release);
ZEND_FUNCTION(aws_crt_credentials_options_set_access_key_id);
ZEND_FUNCTION(aws_crt_credentials_options_set_secret_access_key);
ZEND_FUNCTION(aws_crt_credentials_options_set_session_token);
ZEND_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds);
ZEND_FUNCTION(aws_crt_credentials_new);
ZEND_FUNCTION(aws_crt_credentials_release);
ZEND_FUNCTION(aws_crt_credentials_provider_release);
ZEND_FUNCTION(aws_crt_credentials_provider_static_options_new);
ZEND_FUNCTION(aws_crt_credentials_provider_static_options_release);
ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id);
ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key);
ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token);
ZEND_FUNCTION(aws_crt_credentials_provider_static_new);
static const zend_function_entry ext_functions[] = {
@@ -54,5 +114,20 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(aws_crt_event_loop_group_options_set_max_threads, arginfo_aws_crt_event_loop_group_options_set_max_threads)
ZEND_FE(aws_crt_event_loop_group_new, arginfo_aws_crt_event_loop_group_new)
ZEND_FE(aws_crt_event_loop_group_release, arginfo_aws_crt_event_loop_group_release)
ZEND_FE(aws_crt_credentials_options_new, arginfo_aws_crt_credentials_options_new)
ZEND_FE(aws_crt_credentials_options_release, arginfo_aws_crt_credentials_options_release)
ZEND_FE(aws_crt_credentials_options_set_access_key_id, arginfo_aws_crt_credentials_options_set_access_key_id)
ZEND_FE(aws_crt_credentials_options_set_secret_access_key, arginfo_aws_crt_credentials_options_set_secret_access_key)
ZEND_FE(aws_crt_credentials_options_set_session_token, arginfo_aws_crt_credentials_options_set_session_token)
ZEND_FE(aws_crt_credentials_options_set_expiration_timepoint_seconds, arginfo_aws_crt_credentials_options_set_expiration_timepoint_seconds)
ZEND_FE(aws_crt_credentials_new, arginfo_aws_crt_credentials_new)
ZEND_FE(aws_crt_credentials_release, arginfo_aws_crt_credentials_release)
ZEND_FE(aws_crt_credentials_provider_release, arginfo_aws_crt_credentials_provider_release)
ZEND_FE(aws_crt_credentials_provider_static_options_new, arginfo_aws_crt_credentials_provider_static_options_new)
ZEND_FE(aws_crt_credentials_provider_static_options_release, arginfo_aws_crt_credentials_provider_static_options_release)
ZEND_FE(aws_crt_credentials_provider_static_options_set_access_key_id, arginfo_aws_crt_credentials_provider_static_options_set_access_key_id)
ZEND_FE(aws_crt_credentials_provider_static_options_set_secret_access_key, arginfo_aws_crt_credentials_provider_static_options_set_secret_access_key)
ZEND_FE(aws_crt_credentials_provider_static_options_set_session_token, arginfo_aws_crt_credentials_provider_static_options_set_session_token)
ZEND_FE(aws_crt_credentials_provider_static_new, arginfo_aws_crt_credentials_provider_static_new)
ZEND_FE_END
};
+175
View File
@@ -132,6 +132,181 @@ PHP_FUNCTION(aws_crt_event_loop_group_release) {
aws_crt_event_loop_group_release(elg);
}
PHP_FUNCTION(aws_crt_credentials_options_new) {
aws_crt_credentials_options *options = aws_crt_credentials_options_new();
RETURN_LONG((zend_ulong)options);
}
PHP_FUNCTION(aws_crt_credentials_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials_options_release(options);
}
PHP_FUNCTION(aws_crt_credentials_options_set_access_key_id) {
zend_ulong php_options = 0;
const char *access_key_id = NULL;
size_t access_key_id_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials_options_set_access_key_id(options, (uint8_t *)access_key_id, access_key_id_len);
}
PHP_FUNCTION(aws_crt_credentials_options_set_secret_access_key) {
zend_ulong php_options = 0;
const char *secret_access_key = NULL;
size_t secret_access_key_len = 0;
if (zend_parse_parameters(
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials_options_set_secret_access_key(options, (uint8_t *)secret_access_key, secret_access_key_len);
}
PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
zend_ulong php_options = 0;
const char *session_token = NULL;
size_t session_token_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials_options_set_session_token(options, (uint8_t *)session_token, session_token_len);
}
PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
zend_ulong php_options = 0;
zend_ulong expiration_timepoint_seconds = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_options, &expiration_timepoint_seconds) ==
FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials_options_set_expiration_timepoint_seconds(options, expiration_timepoint_seconds);
}
PHP_FUNCTION(aws_crt_credentials_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_options *options = (void *)php_options;
aws_crt_credentials *credentials = aws_crt_credentials_new(options);
RETURN_LONG((zend_ulong)credentials);
}
PHP_FUNCTION(aws_crt_credentials_release) {
zend_ulong php_credentials = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_credentials) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials *credentials = (void *)php_credentials;
aws_crt_credentials_release(credentials);
}
PHP_FUNCTION(aws_crt_credentials_provider_release) {
zend_ulong php_creds_provider = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_creds_provider) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider *provider = (void *)php_creds_provider;
aws_crt_credentials_provider_release(provider);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_options_new) {
aws_crt_credentials_provider_static_options *options = aws_crt_credentials_provider_static_options_new();
RETURN_LONG((zend_ulong)options);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider_static_options *options = (void *)php_options;
aws_crt_credentials_provider_static_options_release(options);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id) {
zend_ulong php_options = 0;
const char *access_key_id = NULL;
size_t access_key_id_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider_static_options *options = (void *)php_options;
aws_crt_credentials_provider_static_options_set_access_key_id(options, (uint8_t *)access_key_id, access_key_id_len);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key) {
zend_ulong php_options = 0;
const char *secret_access_key = NULL;
size_t secret_access_key_len = 0;
if (zend_parse_parameters(
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider_static_options *options = (void *)php_options;
aws_crt_credentials_provider_static_options_set_secret_access_key(
options, (uint8_t *)secret_access_key, secret_access_key_len);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
zend_ulong php_options = 0;
const char *session_token = NULL;
size_t session_token_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider_static_options *options = (void *)php_options;
aws_crt_credentials_provider_static_options_set_session_token(options, (uint8_t *)session_token, session_token_len);
}
PHP_FUNCTION(aws_crt_credentials_provider_static_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
RETURN_NULL();
}
aws_crt_credentials_provider_static_options *options = (void *)php_options;
aws_crt_credentials_provider *provider = aws_crt_credentials_provider_static_new(options);
RETURN_LONG((zend_ulong)provider);
}
zend_module_entry awscrt_module_entry = {
STANDARD_MODULE_HEADER,
"awscrt",
+1
View File
@@ -39,6 +39,7 @@ ZEND_EXTERN_MODULE_GLOBALS(awscrt)
static const zend_arg_info name[] = {{NULL, 0, NULL, required_num_args, return_reference, 0, 0},
/* PHP5 doesn't really handle type hints well, so elide them */
# undef ZEND_ARG_TYPE_INFO
# define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) \
{#name, sizeof(#name) - 1, NULL, 0, 0, pass_by_ref, allow_null, 0},
#endif