#ifndef AWS_AUTH_CREDENTIALS_H
#define AWS_AUTH_CREDENTIALS_H
#include <aws/auth/auth.h>
#include <aws/common/array_list.h>
#include <aws/common/atomics.h>
#include <aws/common/linked_list.h>
#include <aws/io/io.h>
struct aws_client_bootstrap;
struct aws_auth_http_system_vtable;
struct aws_credentials;
struct aws_credentials_provider;
struct aws_ecc_key_pair;
struct aws_string;
extern const uint16_t aws_sts_assume_role_default_duration_secs;
typedef void(aws_on_get_credentials_callback_fn)(struct aws_credentials *credentials, int error_code, void *user_data);
typedef int(aws_credentials_provider_get_credentials_fn)(
struct aws_credentials_provider *provider,
aws_on_get_credentials_callback_fn callback,
void *user_data);
typedef void(aws_credentials_provider_destroy_fn)(struct aws_credentials_provider *provider);
struct aws_credentials_provider_vtable {
aws_credentials_provider_get_credentials_fn *get_credentials;
aws_credentials_provider_destroy_fn *destroy;
};
typedef void(aws_credentials_provider_shutdown_completed_fn)(void *user_data);
struct aws_credentials_provider_shutdown_options {
aws_credentials_provider_shutdown_completed_fn *shutdown_callback;
void *shutdown_user_data;
};
struct aws_credentials_provider {
struct aws_credentials_provider_vtable *vtable;
struct aws_allocator *allocator;
struct aws_credentials_provider_shutdown_options shutdown_options;
void *impl;
struct aws_atomic_var ref_count;
};
struct aws_credentials_provider_static_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_byte_cursor access_key_id;
struct aws_byte_cursor secret_access_key;
struct aws_byte_cursor session_token;
};
struct aws_credentials_provider_environment_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
};
struct aws_credentials_provider_profile_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_byte_cursor profile_name_override;
struct aws_byte_cursor config_file_name_override;
struct aws_byte_cursor credentials_file_name_override;
struct aws_client_bootstrap *bootstrap;
struct aws_tls_ctx *tls_ctx;
struct aws_auth_http_system_vtable *function_table;
};
struct aws_credentials_provider_cached_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_credentials_provider *source;
uint64_t refresh_time_in_milliseconds;
aws_io_clock_fn *high_res_clock_fn;
aws_io_clock_fn *system_clock_fn;
};
struct aws_credentials_provider_chain_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_credentials_provider **providers;
size_t provider_count;
};
enum aws_imds_protocol_version {
IMDS_PROTOCOL_V2,
IMDS_PROTOCOL_V1,
};
struct aws_credentials_provider_imds_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_client_bootstrap *bootstrap;
enum aws_imds_protocol_version imds_version;
struct aws_auth_http_system_vtable *function_table;
};
struct aws_credentials_provider_ecs_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_client_bootstrap *bootstrap;
struct aws_byte_cursor host;
struct aws_byte_cursor path_and_query;
struct aws_byte_cursor auth_token;
struct aws_tls_ctx *tls_ctx;
struct aws_auth_http_system_vtable *function_table;
uint16_t port;
};
struct aws_credentials_provider_x509_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_client_bootstrap *bootstrap;
const struct aws_tls_connection_options *tls_connection_options;
struct aws_byte_cursor thing_name;
struct aws_byte_cursor role_alias;
struct aws_byte_cursor endpoint;
const struct aws_http_proxy_options *proxy_options;
struct aws_auth_http_system_vtable *function_table;
};
struct aws_credentials_provider_sts_web_identity_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_client_bootstrap *bootstrap;
struct aws_tls_ctx *tls_ctx;
struct aws_auth_http_system_vtable *function_table;
};
struct aws_credentials_provider_sts_options {
struct aws_client_bootstrap *bootstrap;
struct aws_tls_ctx *tls_ctx;
struct aws_credentials_provider *creds_provider;
struct aws_byte_cursor role_arn;
struct aws_byte_cursor session_name;
uint16_t duration_seconds;
const struct aws_http_proxy_options *http_proxy_options;
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_auth_http_system_vtable *function_table;
aws_io_clock_fn *system_clock_fn;
};
struct aws_credentials_provider_process_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_byte_cursor profile_to_use;
};
struct aws_credentials_provider_chain_default_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_client_bootstrap *bootstrap;
struct aws_tls_ctx *tls_ctx;
};
typedef int(aws_credentials_provider_delegate_get_credentials_fn)(
void *delegate_user_data,
aws_on_get_credentials_callback_fn callback,
void *callback_user_data);
struct aws_credentials_provider_delegate_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
aws_credentials_provider_delegate_get_credentials_fn *get_credentials;
void *delegate_user_data;
};
struct aws_cognito_identity_provider_token_pair {
struct aws_byte_cursor identity_provider_name;
struct aws_byte_cursor identity_provider_token;
};
struct aws_credentials_provider_cognito_options {
struct aws_credentials_provider_shutdown_options shutdown_options;
struct aws_byte_cursor endpoint;
struct aws_byte_cursor identity;
struct aws_cognito_identity_provider_token_pair *logins;
size_t login_count;
struct aws_byte_cursor *custom_role_arn;
struct aws_client_bootstrap *bootstrap;
struct aws_tls_ctx *tls_ctx;
const struct aws_http_proxy_options *http_proxy_options;
struct aws_auth_http_system_vtable *function_table;
};
AWS_EXTERN_C_BEGIN
AWS_AUTH_API
struct aws_credentials *aws_credentials_new(
struct aws_allocator *allocator,
struct aws_byte_cursor access_key_id_cursor,
struct aws_byte_cursor secret_access_key_cursor,
struct aws_byte_cursor session_token_cursor,
uint64_t expiration_timepoint_seconds);
AWS_AUTH_API
struct aws_credentials *aws_credentials_new_anonymous(struct aws_allocator *allocator);
AWS_AUTH_API
struct aws_credentials *aws_credentials_new_from_string(
struct aws_allocator *allocator,
const struct aws_string *access_key_id,
const struct aws_string *secret_access_key,
const struct aws_string *session_token,
uint64_t expiration_timepoint_seconds);
AWS_AUTH_API
struct aws_credentials *aws_credentials_new_ecc(
struct aws_allocator *allocator,
struct aws_byte_cursor access_key_id,
struct aws_ecc_key_pair *ecc_key,
struct aws_byte_cursor session_token,
uint64_t expiration_timepoint_in_seconds);
AWS_AUTH_API
struct aws_credentials *aws_credentials_new_ecc_from_aws_credentials(
struct aws_allocator *allocator,
const struct aws_credentials *credentials);
AWS_AUTH_API
void aws_credentials_acquire(const struct aws_credentials *credentials);
AWS_AUTH_API
void aws_credentials_release(const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_byte_cursor aws_credentials_get_access_key_id(const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_byte_cursor aws_credentials_get_secret_access_key(const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_byte_cursor aws_credentials_get_session_token(const struct aws_credentials *credentials);
AWS_AUTH_API
uint64_t aws_credentials_get_expiration_timepoint_seconds(const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_ecc_key_pair *aws_credentials_get_ecc_key_pair(const struct aws_credentials *credentials);
AWS_AUTH_API
bool aws_credentials_is_anonymous(const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_ecc_key_pair *aws_ecc_key_pair_new_ecdsa_p256_key_from_aws_credentials(
struct aws_allocator *allocator,
const struct aws_credentials *credentials);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_release(struct aws_credentials_provider *provider);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_acquire(struct aws_credentials_provider *provider);
AWS_AUTH_API
int aws_credentials_provider_get_credentials(
struct aws_credentials_provider *provider,
aws_on_get_credentials_callback_fn callback,
void *user_data);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_static(
struct aws_allocator *allocator,
const struct aws_credentials_provider_static_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_anonymous(
struct aws_allocator *allocator,
const struct aws_credentials_provider_shutdown_options *shutdown_options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_environment(
struct aws_allocator *allocator,
const struct aws_credentials_provider_environment_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_cached(
struct aws_allocator *allocator,
const struct aws_credentials_provider_cached_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_profile(
struct aws_allocator *allocator,
const struct aws_credentials_provider_profile_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_sts(
struct aws_allocator *allocator,
const struct aws_credentials_provider_sts_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_chain(
struct aws_allocator *allocator,
const struct aws_credentials_provider_chain_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_imds(
struct aws_allocator *allocator,
const struct aws_credentials_provider_imds_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_ecs(
struct aws_allocator *allocator,
const struct aws_credentials_provider_ecs_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_x509(
struct aws_allocator *allocator,
const struct aws_credentials_provider_x509_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_sts_web_identity(
struct aws_allocator *allocator,
const struct aws_credentials_provider_sts_web_identity_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_process(
struct aws_allocator *allocator,
const struct aws_credentials_provider_process_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_delegate(
struct aws_allocator *allocator,
const struct aws_credentials_provider_delegate_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_cognito(
struct aws_allocator *allocator,
const struct aws_credentials_provider_cognito_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_cognito_caching(
struct aws_allocator *allocator,
const struct aws_credentials_provider_cognito_options *options);
AWS_AUTH_API
struct aws_credentials_provider *aws_credentials_provider_new_chain_default(
struct aws_allocator *allocator,
const struct aws_credentials_provider_chain_default_options *options);
AWS_AUTH_API extern const struct aws_auth_http_system_vtable *g_aws_credentials_provider_http_function_table;
AWS_EXTERN_C_END
#endif