Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package aws-c-auth for openSUSE:Factory checked in at 2026-11-26 15:54:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/aws-c-auth (Old) and /work/SRC/openSUSE:Factory/.aws-c-auth.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "aws-c-auth" Thu Nov 26 15:54:04 2026 rev:31 rq:1400632 version:1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/aws-c-auth/aws-c-auth.changes 2026-10-18 20:09:06.532697193 +0200 +++ /work/SRC/openSUSE:Factory/.aws-c-auth.new.1340718/aws-c-auth.changes 2026-11-26 15:54:38.426892485 +0100 @@ -1,0 +2,13 @@ +Tue Nov 24 12:33:08 UTC 2026 - John Paul Adrian Glaubitz <[email protected]> + +- Update to verson 1.1.0 + * Actually use the tls context in the imds client if appropriate + by @bretambrose in (#313) + * Add optional sticky provider chain by @rakshil14-2 in (#317) + * Fix a crash triggered by failure to fully construct an IMDS + client by @bretambrose in (#316) +- Bump library_version to 1.1.0 +- Bump library_pkg to 1_1 +- Update Provides and Obsoletes for previous shared library version + +------------------------------------------------------------------- Old: ---- v1.0.0.tar.gz New: ---- v1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ aws-c-auth.spec ++++++ --- /var/tmp/diff_new_pack.3ryZ9h/_old 2026-11-26 15:54:40.004959265 +0100 +++ /var/tmp/diff_new_pack.3ryZ9h/_new 2026-11-26 15:54:40.006959350 +0100 @@ -16,11 +16,11 @@ # -%define library_version 1.0.0 -%define library_pkg 1_0 +%define library_version 1.1.0 +%define library_pkg 1_1 %define library_soversion 1 Name: aws-c-auth -Version: 1.0.0 +Version: 1.1.0 Release: 0 Summary: AWS C99 library implementation of AWS client-side authentication License: Apache-2.0 @@ -50,8 +50,8 @@ %package -n lib%{name}%{library_pkg} Summary: Shared library files for aws-c-auth library Group: Development/Libraries/C and C++ -Provides: lib%{name}1_0_0 = %{version} -Obsoletes: lib%{name}1_0_0 < %{version} +Provides: lib%{name}1_0 = %{version} +Obsoletes: lib%{name}1_0 < %{version} %description -n lib%{name}%{library_pkg} AWS C99 library implementation of AWS client-side authentication: @@ -98,7 +98,7 @@ %license LICENSE %{_libdir}/lib%{name}.so.%{library_soversion} %{_libdir}/lib%{name}.so.%{library_version} -%{_libdir}/lib%{name}.so.1.0 +%{_libdir}/lib%{name}.so.1.1 %files devel %{_libdir}/cmake/%{name}/ ++++++ v1.0.0.tar.gz -> v1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/.github/workflows/ci.yml new/aws-c-auth-1.1.0/.github/workflows/ci.yml --- old/aws-c-auth-1.0.0/.github/workflows/ci.yml 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/.github/workflows/ci.yml 2026-11-16 19:54:16.000000000 +0100 @@ -144,7 +144,11 @@ python .\aws-c-auth\build\deps\aws-c-common\scripts\appverifier_ctest.py --build_directory .\aws-c-auth\build\aws-c-auth macos: - runs-on: macos-14 # latest + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: [macos-15, macos-latest] steps: - uses: aws-actions/configure-aws-credentials@v4 with: @@ -157,7 +161,11 @@ ./builder build -p ${{ env.PACKAGE_NAME }} macos-x64: - runs-on: macos-14-large # latest + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: [macos-15-large, macos-latest-large] steps: - uses: aws-actions/configure-aws-credentials@v4 with: @@ -170,7 +178,11 @@ ./builder build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON macos-s2n: - runs-on: macos-14 # latest + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: [macos-15, macos-latest] env: AWS_CRT_USE_NON_FIPS_TLS_13: 1 steps: @@ -185,7 +197,11 @@ ./builder build -p ${{ env.PACKAGE_NAME }} macos-x64-s2n: - runs-on: macos-14-large # latest + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: [macos-15-large, macos-latest-large] env: AWS_CRT_USE_NON_FIPS_TLS_13: 1 steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/VERSION new/aws-c-auth-1.1.0/VERSION --- old/aws-c-auth-1.0.0/VERSION 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/VERSION 2026-11-16 19:54:16.000000000 +0100 @@ -1 +1 @@ -1.0.0 +1.1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/include/aws/auth/credentials.h new/aws-c-auth-1.1.0/include/aws/auth/credentials.h --- old/aws-c-auth-1.0.0/include/aws/auth/credentials.h 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/include/aws/auth/credentials.h 2026-11-16 19:54:16.000000000 +0100 @@ -189,6 +189,14 @@ * Number of elements in the array of credentials providers */ size_t provider_count; + + /* + * (Optional) + * If enabled, the chain remembers the first provider that returns credentials and only queries that provider + * afterwards. A failure from that provider is returned to the caller; the chain does not fall back to other + * providers. Defaults to false. + */ + bool pin_credential_provider; }; /* @@ -718,6 +726,13 @@ * aws_http_credentials_provider.h for more information. */ const struct proxy_env_var_settings *proxy_ev_settings; + + /* + * (Optional) + * If enabled, the chain remembers the first provider that returns credentials and only queries that provider + * afterwards. See aws_credentials_provider_chain_options. Defaults to false. + */ + bool pin_credential_provider; }; typedef int(aws_credentials_provider_delegate_get_credentials_fn)( @@ -851,8 +866,9 @@ struct aws_byte_cursor login_session; /* - * Required - * Region the AWS login CreateOAuth2Token call + * Optional. + * Region for the AWS login CreateOAuth2Token call. The provider uses the first of: the cached token's + * signInRegion, this option, then the profile's region. */ struct aws_byte_cursor login_region; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/include/aws/auth/private/login_token_utils.h new/aws-c-auth-1.1.0/include/aws/auth/private/login_token_utils.h --- old/aws-c-auth-1.0.0/include/aws/auth/private/login_token_utils.h 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/include/aws/auth/private/login_token_utils.h 2026-11-16 19:54:16.000000000 +0100 @@ -39,6 +39,12 @@ struct aws_byte_cursor aws_login_token_get_account_id(struct aws_login_token *token); /* + * Returns the token's signInRegion, or an empty cursor if the token does not record one. + */ +AWS_AUTH_API +struct aws_byte_cursor aws_login_token_get_sign_in_region(struct aws_login_token *token); + +/* * Setter for access key id. */ AWS_AUTH_API @@ -97,6 +103,18 @@ struct aws_byte_buf *header_value); /* + * Reads the signInRegion recorded in a cached login token, which names the region the refresh token was issued in, + * into out_region. The caller must clean up out_region. If the field is absent or empty, out_region is left empty and + * the call still succeeds. Fails if the file cannot be read or parsed. The token's other fields are not validated, so + * this also works for a token whose credentials have expired. + */ +AWS_AUTH_API +int aws_login_token_read_sign_in_region( + struct aws_allocator *allocator, + struct aws_byte_cursor file_path, + struct aws_byte_buf *out_region); + +/* * Constructs a path to a login cached credential i.e. * * ~/.aws/login/cache/${SHA_256_OF_LOGIN_SESSION}.json diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/aws_imds_client.c new/aws-c-auth-1.1.0/source/aws_imds_client.c --- old/aws-c-auth-1.0.0/source/aws_imds_client.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/aws_imds_client.c 2026-11-16 19:54:16.000000000 +0100 @@ -190,8 +190,14 @@ /* Clean up endpoint host if we allocated it */ aws_string_destroy(client->endpoint_host); - client->function_table->aws_http_connection_manager_release(client->connection_manager); - /* freeing the client takes place in the shutdown callback below */ + if (client->connection_manager) { + /* freeing the client takes place in the shutdown callback above */ + client->function_table->aws_http_connection_manager_release(client->connection_manager); + } else { + /* no connection manager so no callback, clean up directly because we don't want to invoke the shutdown callback + * either */ + aws_mem_release(client->allocator, client); + } } static void s_on_connection_manager_shutdown(void *user_data) { @@ -312,6 +318,8 @@ AWS_LOGF_ERROR(AWS_LS_IMDS_CLIENT, "Failed to set SNI hostname for TLS connection"); goto on_error; } + + manager_options.tls_connection_options = &tls_connection_options; #endif /* BYO_CRYPTO */ } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/aws_signing.c new/aws-c-auth-1.1.0/source/aws_signing.c --- old/aws-c-auth-1.0.0/source/aws_signing.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/aws_signing.c 2026-11-16 19:54:16.000000000 +0100 @@ -112,7 +112,7 @@ allocator, 10, aws_hash_byte_cursor_ptr_ignore_case, - (aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case, + aws_byte_cursor_eq_ignore_case_cb, NULL, NULL)) { return AWS_OP_ERR; @@ -168,7 +168,7 @@ allocator, 10, aws_hash_byte_cursor_ptr_ignore_case, - (aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case, + aws_byte_cursor_eq_ignore_case_cb, NULL, NULL)) { return AWS_OP_ERR; @@ -207,7 +207,7 @@ allocator, 10, aws_hash_byte_cursor_ptr_ignore_case, - (aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case, + aws_byte_cursor_eq_ignore_case_cb, NULL, NULL)) { return AWS_OP_ERR; @@ -2259,7 +2259,7 @@ cleanup: aws_byte_buf_clean_up_secure(&secret_key); - aws_byte_buf_clean_up(&output); + aws_byte_buf_clean_up_secure(&output); aws_byte_buf_clean_up(&date_buf); return result; @@ -2302,7 +2302,7 @@ cleanup: - aws_byte_buf_clean_up(&key); + aws_byte_buf_clean_up_secure(&key); aws_byte_buf_clean_up(&digest); return result; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials.c new/aws-c-auth-1.1.0/source/credentials.c --- old/aws-c-auth-1.0.0/source/credentials.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials.c 2026-11-16 19:54:16.000000000 +0100 @@ -188,13 +188,13 @@ } switch (credentials->identity_type) { case AWS_CREDENTIALS_IDENTITY: - aws_string_destroy(credentials->identity.credentials_identity.access_key_id); + aws_string_destroy_secure(credentials->identity.credentials_identity.access_key_id); aws_string_destroy_secure(credentials->identity.credentials_identity.secret_access_key); aws_string_destroy_secure(credentials->identity.credentials_identity.session_token); aws_string_destroy_secure(credentials->identity.credentials_identity.account_id); break; case ECC_IDENTITY: - aws_string_destroy(credentials->identity.ecc_identity.access_key_id); + aws_string_destroy_secure(credentials->identity.ecc_identity.access_key_id); aws_string_destroy_secure(credentials->identity.ecc_identity.session_token); aws_ecc_key_pair_release(credentials->identity.ecc_identity.ecc_key); break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_chain.c new/aws-c-auth-1.1.0/source/credentials_provider_chain.c --- old/aws-c-auth-1.0.0/source/credentials_provider_chain.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_chain.c 2026-11-16 19:54:16.000000000 +0100 @@ -9,6 +9,9 @@ struct aws_credentials_provider_chain_impl { struct aws_array_list providers; + bool pin_credential_provider; + /* Provider that returned credentials first; NULL until then */ + struct aws_atomic_var pinned_provider; }; struct aws_credentials_provider_chain_user_data { @@ -17,6 +20,8 @@ size_t current_provider_index; aws_on_get_credentials_callback_fn *original_callback; void *original_user_data; + /* Query sent only to the pinned provider */ + bool pinned_query; }; static void s_aws_provider_chain_member_callback(struct aws_credentials *credentials, int error_code, void *user_data) { @@ -26,6 +31,32 @@ size_t provider_count = aws_array_list_length(&impl->providers); + /* Pinned query: return the result as is, never fall through */ + if (wrapped_user_data->pinned_query) { + AWS_LOGF_DEBUG( + AWS_LS_AUTH_CREDENTIALS_PROVIDER, + "(id=%p) Credentials provider chain pinned provider returned %s credentials and error code %d", + (void *)provider, + (credentials != NULL) ? "valid" : "invalid", + error_code); + + goto on_terminate_chain; + } + + /* Pin the first member that returns credentials */ + if (credentials != NULL && impl->pin_credential_provider) { + struct aws_credentials_provider *member = NULL; + void *expected = NULL; + if (!aws_array_list_get_at(&impl->providers, &member, wrapped_user_data->current_provider_index) && + aws_atomic_compare_exchange_ptr(&impl->pinned_provider, &expected, member)) { + AWS_LOGF_INFO( + AWS_LS_AUTH_CREDENTIALS_PROVIDER, + "(id=%p) Credentials provider chain pinned member #%zu", + (void *)provider, + wrapped_user_data->current_provider_index + 1); + } + } + if (credentials != NULL || wrapped_user_data->current_provider_index + 1 >= provider_count) { AWS_LOGF_INFO( AWS_LS_AUTH_CREDENTIALS_PROVIDER, @@ -82,7 +113,14 @@ struct aws_credentials_provider_chain_impl *impl = provider->impl; struct aws_credentials_provider *first_provider = NULL; - if (aws_array_list_get_at(&impl->providers, &first_provider, 0)) { + bool pinned_query = false; + if (impl->pin_credential_provider) { + first_provider = aws_atomic_load_ptr(&impl->pinned_provider); + pinned_query = first_provider != NULL; + } + + /* Nothing pinned: walk from the first member */ + if (first_provider == NULL && aws_array_list_get_at(&impl->providers, &first_provider, 0)) { return AWS_OP_ERR; } @@ -99,13 +137,15 @@ wrapped_user_data->current_provider_index = 0; wrapped_user_data->original_user_data = user_data; wrapped_user_data->original_callback = callback; + wrapped_user_data->pinned_query = pinned_query; aws_credentials_provider_acquire(provider); AWS_LOGF_DEBUG( AWS_LS_AUTH_CREDENTIALS_PROVIDER, - "(id=%p) Credentials provider chain get credentials dispatch", - (void *)provider); + "(id=%p) Credentials provider chain get credentials dispatch%s", + (void *)provider, + pinned_query ? " to pinned provider" : ""); aws_credentials_provider_get_credentials(first_provider, s_aws_provider_chain_member_callback, wrapped_user_data); @@ -184,6 +224,8 @@ } provider->shutdown_options = options->shutdown_options; + impl->pin_credential_provider = options->pin_credential_provider; + aws_atomic_init_ptr(&impl->pinned_provider, NULL); return provider; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_default_chain.c new/aws-c-auth-1.1.0/source/credentials_provider_default_chain.c --- old/aws-c-auth-1.0.0/source/credentials_provider_default_chain.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_default_chain.c 2026-11-16 19:54:16.000000000 +0100 @@ -327,6 +327,7 @@ struct aws_credentials_provider_chain_options chain_options = { .provider_count = index, .providers = providers, + .pin_credential_provider = options->pin_credential_provider, }; chain_provider = aws_credentials_provider_new_chain(allocator, &chain_options); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_environment.c new/aws-c-auth-1.1.0/source/credentials_provider_environment.c --- old/aws-c-auth-1.0.0/source/credentials_provider_environment.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_environment.c 2026-11-16 19:54:16.000000000 +0100 @@ -63,10 +63,10 @@ callback(credentials, error_code, user_data); aws_credentials_release(credentials); - aws_string_destroy(account_id); - aws_string_destroy(session_token); - aws_string_destroy(secret_access_key); - aws_string_destroy(access_key_id); + aws_string_destroy_secure(account_id); + aws_string_destroy_secure(session_token); + aws_string_destroy_secure(secret_access_key); + aws_string_destroy_secure(access_key_id); return AWS_OP_SUCCESS; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_login.c new/aws-c-auth-1.1.0/source/credentials_provider_login.c --- old/aws-c-auth-1.0.0/source/credentials_provider_login.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_login.c 2026-11-16 19:54:16.000000000 +0100 @@ -105,13 +105,50 @@ goto on_finish; } - if (options->login_region.len > 0) { - parameters->login_region = aws_string_new_from_cursor(allocator, &options->login_region); + if (options->login_cache_directory_override.len > 0) { + parameters->login_directory_override = + aws_string_new_from_cursor(allocator, &options->login_cache_directory_override); } else { - const struct aws_profile_property *login_region = aws_profile_get_property(profile, s_login_region); - if (login_region) { - parameters->login_region = - aws_string_new_from_string(allocator, aws_profile_property_get_value(login_region)); + if (aws_get_environment_value(allocator, s_login_cache_env_var, ¶meters->login_directory_override)) { + AWS_LOGF_TRACE(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "login: no override for cache dir found"); + } + } + + /* + * Refresh tokens are regional, so prefer the region the cached token was issued in. Fall back to the configured + * region for tokens that do not record one. + */ + struct aws_byte_buf token_path; + AWS_ZERO_STRUCT(token_path); + struct aws_byte_buf sign_in_region; + AWS_ZERO_STRUCT(sign_in_region); + const char *region_source = NULL; + if (aws_login_token_construct_token_path( + allocator, parameters->login_session, parameters->login_directory_override, &token_path) || + aws_login_token_read_sign_in_region(allocator, aws_byte_cursor_from_buf(&token_path), &sign_in_region)) { + /* a missing token file is normal before the first login, so this is not an error */ + AWS_LOGF_DEBUG( + AWS_LS_AUTH_CREDENTIALS_PROVIDER, + "login: could not read signInRegion from the cached token: %s", + aws_error_debug_str(aws_last_error())); + } else if (sign_in_region.len > 0) { + parameters->login_region = aws_string_new_from_buf(allocator, &sign_in_region); + region_source = "cached token"; + } + aws_byte_buf_clean_up(&sign_in_region); + aws_byte_buf_clean_up(&token_path); + + if (!parameters->login_region) { + if (options->login_region.len > 0) { + parameters->login_region = aws_string_new_from_cursor(allocator, &options->login_region); + region_source = "provider options"; + } else { + const struct aws_profile_property *login_region = aws_profile_get_property(profile, s_login_region); + if (login_region) { + parameters->login_region = + aws_string_new_from_string(allocator, aws_profile_property_get_value(login_region)); + region_source = "profile"; + } } } @@ -120,24 +157,19 @@ aws_raise_error(AWS_AUTH_CREDENTIALS_PROVIDER_LOGIN_REGION_MISSING); goto on_finish; } - - if (options->login_cache_directory_override.len > 0) { - parameters->login_directory_override = - aws_string_new_from_cursor(allocator, &options->login_cache_directory_override); - } else { - if (aws_get_environment_value(allocator, s_login_cache_env_var, ¶meters->login_directory_override)) { - AWS_LOGF_TRACE(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "login: no override for cache dir found"); - } - } + AWS_LOGF_DEBUG( + AWS_LS_AUTH_CREDENTIALS_PROVIDER, + "login: using region %s from the %s", + aws_string_c_str(parameters->login_region), + region_source); const struct aws_byte_cursor suffix_override = aws_byte_cursor_from_c_str("aws.amazon.com"); - struct aws_string *region = aws_string_new_from_cursor(allocator, &options->login_region); /* determine endpoint */ if (aws_credentials_provider_construct_endpoint( allocator, ¶meters->endpoint, - region, + parameters->login_region, s_login_service_host_prefix, s_login_service_env_name, s_login_service_name, @@ -146,13 +178,11 @@ &suffix_override, true)) { AWS_LOGF_ERROR(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "Failed to construct login endpoint"); - aws_string_destroy(region); goto on_finish; } AWS_LOGF_DEBUG( AWS_LS_AUTH_CREDENTIALS_PROVIDER, "Successfully loaded all required parameters for login credentials provider."); - aws_string_destroy(region); success = true; on_finish: @@ -223,6 +253,20 @@ struct login_request_data *request_data = http_query_context->request_data; request_data->token = token; + /* + * The endpoint is fixed when the provider is created, so a later login in another region is not picked up. + */ + struct aws_byte_cursor token_region = aws_login_token_get_sign_in_region(token); + if (token_region.len > 0 && !aws_string_eq_byte_cursor(parameters->login_region, &token_region)) { + AWS_LOGF_WARN( + AWS_LS_AUTH_CREDENTIALS_PROVIDER, + "(id=%p) login: the cached token was issued in " PRInSTR + " but this provider refreshes in %s. Recreate the provider to refresh in the token's region.", + (void *)http_query_context->provider, + AWS_BYTE_CURSOR_PRI(token_region), + aws_string_c_str(parameters->login_region)); + } + /* Set path and query */ struct aws_byte_cursor path_cursor = aws_byte_cursor_from_string(s_login_endpoint); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_sts.c new/aws-c-auth-1.1.0/source/credentials_provider_sts.c --- old/aws-c-auth-1.0.0/source/credentials_provider_sts.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_sts.c 2026-11-16 19:54:16.000000000 +0100 @@ -120,16 +120,16 @@ aws_byte_buf_clean_up(&user_data->output_buf); - aws_string_destroy(user_data->access_key_id); + aws_string_destroy_secure(user_data->access_key_id); user_data->access_key_id = NULL; aws_string_destroy_secure(user_data->secret_access_key); user_data->secret_access_key = NULL; - aws_string_destroy(user_data->session_token); + aws_string_destroy_secure(user_data->session_token); user_data->session_token = NULL; - aws_string_destroy(user_data->account_id); + aws_string_destroy_secure(user_data->account_id); user_data->account_id = NULL; } static void s_clean_up_user_data(struct sts_creds_provider_user_data *user_data) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_provider_sts_web_identity.c new/aws-c-auth-1.1.0/source/credentials_provider_sts_web_identity.c --- old/aws-c-auth-1.0.0/source/credentials_provider_sts_web_identity.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_provider_sts_web_identity.c 2026-11-16 19:54:16.000000000 +0100 @@ -90,7 +90,7 @@ aws_http_message_destroy(user_data->request); user_data->request = NULL; - aws_string_destroy(user_data->access_key_id); + aws_string_destroy_secure(user_data->access_key_id); user_data->access_key_id = NULL; aws_string_destroy_secure(user_data->secret_access_key); @@ -99,7 +99,7 @@ aws_string_destroy_secure(user_data->session_token); user_data->session_token = NULL; - aws_string_destroy(user_data->account_id); + aws_string_destroy_secure(user_data->account_id); user_data->account_id = NULL; } @@ -117,7 +117,7 @@ s_user_data_reset_request_and_response(user_data); aws_byte_buf_clean_up(&user_data->response); - aws_string_destroy(user_data->access_key_id); + aws_string_destroy_secure(user_data->access_key_id); aws_string_destroy_secure(user_data->secret_access_key); aws_string_destroy_secure(user_data->session_token); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/credentials_utils.c new/aws-c-auth-1.1.0/source/credentials_utils.c --- old/aws-c-auth-1.0.0/source/credentials_utils.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/credentials_utils.c 2026-11-16 19:54:16.000000000 +0100 @@ -363,6 +363,10 @@ static struct aws_byte_cursor s_cn_region_prefix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("cn-"); static struct aws_byte_cursor s_aws_cn_dns_suffix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("amazonaws.com.cn"); +/* AWS EUSC */ +static struct aws_byte_cursor s_eusc_region_prefix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("eusc-"); +static struct aws_byte_cursor s_aws_eusc_dns_suffix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("amazonaws.eu"); + /* AWS ISO */ static struct aws_byte_cursor s_iso_region_prefix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("us-iso-"); static struct aws_byte_cursor s_aws_iso_dns_suffix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("c2s.ic.gov"); @@ -522,6 +526,10 @@ if (aws_byte_buf_append_dynamic(&endpoint, &s_aws_cn_dns_suffix)) { goto on_error; } + } else if (aws_byte_cursor_starts_with(®ion_cur, &s_eusc_region_prefix)) { /* AWS EUSC partition */ + if (aws_byte_buf_append_dynamic(&endpoint, &s_aws_eusc_dns_suffix)) { + goto on_error; + } } else if (aws_byte_cursor_starts_with(®ion_cur, &s_iso_region_prefix)) { /* AWS ISO partition */ if (aws_byte_buf_append_dynamic(&endpoint, &s_aws_iso_dns_suffix)) { goto on_error; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/login_token_utils.c new/aws-c-auth-1.1.0/source/login_token_utils.c --- old/aws-c-auth-1.0.0/source/login_token_utils.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/login_token_utils.c 2026-11-16 19:54:16.000000000 +0100 @@ -32,6 +32,7 @@ AWS_STATIC_STRING_FROM_LITERAL(s_login_id_token_key, "idToken"); AWS_STATIC_STRING_FROM_LITERAL(s_login_client_id_key, "clientId"); AWS_STATIC_STRING_FROM_LITERAL(s_login_dpop_key, "dpopKey"); +AWS_STATIC_STRING_FROM_LITERAL(s_login_sign_in_region_key, "signInRegion"); AWS_STATIC_STRING_FROM_LITERAL(s_login_grant_type_key, "grantType"); AWS_STATIC_STRING_FROM_LITERAL(s_login_grant_type_value, "refresh_token"); @@ -69,6 +70,8 @@ struct aws_byte_cursor id_token; struct aws_byte_cursor client_id; struct aws_byte_cursor dpop_key; + /* optional, empty when the token file does not record it */ + struct aws_byte_cursor sign_in_region; }; struct aws_login_refresh_response { @@ -84,6 +87,10 @@ return token->account_id; } +struct aws_byte_cursor aws_login_token_get_sign_in_region(struct aws_login_token *token) { + return token->sign_in_region; +} + void aws_login_token_set_access_key_id(struct aws_login_token *token, struct aws_byte_cursor value) { token->access_key_id = value; } @@ -139,6 +146,45 @@ return refresh_token; } +int aws_login_token_read_sign_in_region( + struct aws_allocator *allocator, + struct aws_byte_cursor file_path, + struct aws_byte_buf *out_region) { + int result = AWS_OP_ERR; + struct aws_json_value *document = NULL; + struct aws_json_value *value = NULL; + struct aws_byte_cursor region; + AWS_ZERO_STRUCT(region); + struct aws_byte_buf contents; + AWS_ZERO_STRUCT(contents); + + struct aws_string *file_path_string = aws_string_new_from_cursor(allocator, &file_path); + if (aws_byte_buf_init_from_file(&contents, allocator, aws_string_c_str(file_path_string))) { + goto on_finish; + } + + document = aws_json_value_new_from_string(allocator, aws_byte_cursor_from_buf(&contents)); + if (!document) { + aws_raise_error(AWS_AUTH_CREDENTIALS_PROVIDER_LOGIN_FAILED_TO_CREATE_TOKEN); + goto on_finish; + } + + value = aws_json_value_get_from_object(document, aws_byte_cursor_from_string(s_login_sign_in_region_key)); + if (value && aws_json_value_is_string(value) && aws_json_value_get_string(value, ®ion) == AWS_OP_SUCCESS && + region.len > 0) { + if (aws_byte_buf_init_copy_from_cursor(out_region, allocator, region)) { + goto on_finish; + } + } + result = AWS_OP_SUCCESS; + +on_finish: + aws_json_value_destroy(document); + aws_byte_buf_clean_up_secure(&contents); + aws_string_destroy(file_path_string); + return result; +} + int aws_login_token_construct_token_path( struct aws_allocator *allocator, const struct aws_string *input, @@ -378,6 +424,13 @@ goto on_error; } + AWS_ZERO_STRUCT(token->sign_in_region); + struct aws_json_value *sign_in_region = + aws_json_value_get_from_object(document_root, aws_byte_cursor_from_string(s_login_sign_in_region_key)); + if (sign_in_region && aws_json_value_is_string(sign_in_region)) { + aws_json_value_get_string(sign_in_region, &token->sign_in_region); + } + // check that the token has not expired yet struct aws_date_time now; aws_date_time_init_now(&now); @@ -647,6 +700,17 @@ goto on_error; } + if (token->sign_in_region.len > 0 && s_write_to_json_node( + allocator, + login_json, + s_new_string_from_cursor_json_value, + s_add_json_value_to_parent, + aws_string_c_str(s_login_sign_in_region_key), + &token->sign_in_region)) { + aws_json_value_destroy(login_json); + goto on_error; + } + if (aws_byte_buf_init(&output_buffer, allocator, TOKEN_BUFFER_SIZE) || aws_byte_buf_append_json_string_formatted(login_json, &output_buffer)) { aws_byte_buf_clean_up_secure(&output_buffer); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/source/sigv4_http_request.c new/aws-c-auth-1.1.0/source/sigv4_http_request.c --- old/aws-c-auth-1.0.0/source/sigv4_http_request.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/source/sigv4_http_request.c 2026-11-16 19:54:16.000000000 +0100 @@ -117,8 +117,8 @@ aws_array_list_clean_up(&query_params); - aws_uri_clean_up(&new_uri); - aws_uri_clean_up(&old_uri); + aws_uri_clean_up_secure(&new_uri); + aws_uri_clean_up_secure(&old_uri); return result; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/CMakeLists.txt new/aws-c-auth-1.1.0/tests/CMakeLists.txt --- old/aws-c-auth-1.0.0/tests/CMakeLists.txt 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/CMakeLists.txt 2026-11-16 19:54:16.000000000 +0100 @@ -25,6 +25,9 @@ add_test_case(credentials_provider_first_in_chain_test) add_test_case(credentials_provider_second_in_chain_test) add_test_case(credentials_provider_null_chain_test) +add_test_case(credentials_provider_chain_pin_test) +add_test_case(credentials_provider_chain_pin_disabled_test) +add_test_case(credentials_provider_chain_pin_all_fail_test) add_net_test_case(credentials_provider_default_basic_test) add_net_test_case(credentials_provider_default_manual_tls_test) add_net_test_case(credentials_provider_default_chain_disable_environment_test) @@ -193,6 +196,11 @@ add_net_test_case(credentials_provider_login_bad_response) add_net_test_case(credentials_provider_login_retryable_error) add_net_test_case(credentials_provider_login_basic_success) +add_net_test_case(credentials_provider_login_refresh_preserves_sign_in_region) +add_net_test_case(credentials_provider_login_refresh_does_not_add_sign_in_region) +add_net_test_case(credentials_provider_login_refresh_uses_sign_in_region) +add_net_test_case(credentials_provider_login_refresh_falls_back_to_option_region) +add_net_test_case(credentials_provider_login_refresh_falls_back_to_profile_region) add_net_test_case(credentials_provider_login_basic_success_after_failure) add_test_case(imds_client_new_release) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/credentials_provider_login_tests.c new/aws-c-auth-1.1.0/tests/credentials_provider_login_tests.c --- old/aws-c-auth-1.0.0/tests/credentials_provider_login_tests.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/credentials_provider_login_tests.c 2026-11-16 19:54:16.000000000 +0100 @@ -10,6 +10,7 @@ #include <aws/common/clock.h> #include <aws/common/environment.h> +#include <aws/common/json.h> #include <aws/http/status_code.h> AWS_STATIC_STRING_FROM_LITERAL(s_login_profile, "login"); @@ -705,6 +706,185 @@ } AWS_TEST_CASE(credentials_provider_login_basic_success, s_credentials_provider_login_basic_success); +AWS_STATIC_STRING_FROM_LITERAL( + s_login_token_with_sign_in_region, + "{\"accessToken\":{\"accessKeyId\":\"shinji\",\"secretAccessKey\":\"rei\",\"sessionToken\":\"asuka\",\"accountId\":" + "\"123456789012\",\"expiresAt\":\"3000-09-13T00:00:00Z\"},\"tokenType\":\"urn:aws:" + "params:oauth:token-type:access_token_sigv4\",\"clientId\":\"arn:aws:signin:::devtools/" + "same-device\",\"refreshToken\":\"Kaworu\",\"idToken\":\"toji\",\"signInRegion\":\"eu-west-1\",\"dpopKey\":\"-----" + "BEGIN EC PRIVATE KEY-----\nMHcCAQEEIBDOA9C+wyEeYZYLa9fPAzzZLi43suMHc7GqUSD2wP9VoAoGCCqGSM49\nAwEHoUQDQgAE8p+" + "kv53xQZSVnOvFFQZgYXafB8IQXc0boBiNwruEaIzNEi5/7m0I\nP8t5hwdP1bEyoLcHx9sIDcPy8W9str/Kow==\n-----END EC PRIVATE " + "KEY-----\n\"}"); + +static int s_assert_string_member(const struct aws_json_value *object, const char *key, const char *expected) { + struct aws_json_value *member = aws_json_value_get_from_object_c_str(object, key); + ASSERT_NOT_NULL(member); + struct aws_byte_cursor value; + ASSERT_SUCCESS(aws_json_value_get_string(member, &value)); + ASSERT_CURSOR_VALUE_CSTRING_EQUALS(value, expected); + return AWS_OP_SUCCESS; +} + +typedef int(written_token_check_fn)(const struct aws_json_value *written); + +/* Refreshes the given cached token through the provider, then checks the token file it wrote back. */ +static int s_refresh_and_check_token_file( + struct aws_allocator *allocator, + const struct aws_string *cached_token, + struct aws_byte_cursor login_region, + written_token_check_fn *check) { + + aws_credentials_provider_http_mock_tester_init(allocator); + + struct aws_string *tmp_home; + ASSERT_SUCCESS(aws_create_random_home_directory(allocator, &tmp_home)); + + struct aws_byte_buf token_path; + AWS_ZERO_STRUCT(token_path); + aws_login_token_construct_token_path(allocator, s_login_session, tmp_home, &token_path); + struct aws_string *token_path_string = aws_string_new_from_buf(allocator, &token_path); + ASSERT_SUCCESS(aws_create_directory_components(allocator, token_path_string)); + ASSERT_SUCCESS(aws_create_profile_file(token_path_string, cached_token)); + + s_aws_credentials_provider_login_test_init_config_profile(allocator, s_login_config_contents); + + struct aws_byte_cursor good_response_cursor = aws_byte_cursor_from_string(s_good_response); + aws_array_list_push_back(&credentials_provider_http_mock_tester.response_data_callbacks, &good_response_cursor); + + mock_aws_set_system_time(0); + struct aws_credentials_provider_login_options options = { + .bootstrap = credentials_provider_http_mock_tester.bootstrap, + .tls_ctx = credentials_provider_http_mock_tester.tls_ctx, + .function_table = &aws_credentials_provider_http_mock_function_table, + .shutdown_options = + { + .shutdown_callback = aws_credentials_provider_http_mock_on_shutdown_complete, + .shutdown_user_data = NULL, + }, + .system_clock_fn = mock_aws_get_system_time, + .login_cache_directory_override = aws_byte_cursor_from_string(tmp_home), + .login_region = login_region, + }; + + struct aws_credentials_provider *provider = aws_credentials_provider_new_login(allocator, &options); + ASSERT_NOT_NULL(provider); + + aws_credentials_provider_get_credentials( + provider, aws_credentials_provider_http_mock_get_credentials_callback, NULL); + aws_credentials_provider_http_mock_wait_for_credentials_result(); + ASSERT_SUCCESS(s_verify_credentials(true /*request made*/, true /*get creds*/, 1 /*expected attempts*/)); + + aws_credentials_provider_release(provider); + aws_credentials_provider_http_mock_wait_for_shutdown_callback(); + + struct aws_byte_buf contents; + ASSERT_SUCCESS(aws_byte_buf_init_from_file(&contents, allocator, aws_string_c_str(token_path_string))); + struct aws_json_value *written = aws_json_value_new_from_string(allocator, aws_byte_cursor_from_buf(&contents)); + ASSERT_NOT_NULL(written); + ASSERT_SUCCESS(check(written)); + + aws_json_value_destroy(written); + aws_byte_buf_clean_up(&contents); + aws_credentials_provider_http_mock_tester_cleanup(); + aws_directory_delete(tmp_home, true); + aws_string_destroy(tmp_home); + aws_byte_buf_clean_up(&token_path); + aws_string_destroy(token_path_string); + return AWS_OP_SUCCESS; +} + +static int s_check_sign_in_region_preserved(const struct aws_json_value *written) { + /* signInRegion survives the rewrite, alongside the refreshed fields */ + ASSERT_SUCCESS(s_assert_string_member(written, "signInRegion", "eu-west-1")); + ASSERT_SUCCESS(s_assert_string_member(written, "refreshToken", "Kensuke")); + struct aws_json_value *access_token = aws_json_value_get_from_object_c_str(written, "accessToken"); + ASSERT_NOT_NULL(access_token); + ASSERT_SUCCESS(s_assert_string_member(access_token, "accessKeyId", "Ritsuko")); + return AWS_OP_SUCCESS; +} + +static int s_credentials_provider_login_refresh_preserves_sign_in_region(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + return s_refresh_and_check_token_file( + allocator, s_login_token_with_sign_in_region, (struct aws_byte_cursor){0}, s_check_sign_in_region_preserved); +} +AWS_TEST_CASE( + credentials_provider_login_refresh_preserves_sign_in_region, + s_credentials_provider_login_refresh_preserves_sign_in_region); + +static int s_check_sign_in_region_not_added(const struct aws_json_value *written) { + ASSERT_FALSE(aws_json_value_has_key_c_str(written, "signInRegion")); + ASSERT_SUCCESS(s_assert_string_member(written, "refreshToken", "Kensuke")); + return AWS_OP_SUCCESS; +} + +static int s_credentials_provider_login_refresh_does_not_add_sign_in_region( + struct aws_allocator *allocator, + void *ctx) { + (void)ctx; + return s_refresh_and_check_token_file( + allocator, s_login_token_good, (struct aws_byte_cursor){0}, s_check_sign_in_region_not_added); +} +AWS_TEST_CASE( + credentials_provider_login_refresh_does_not_add_sign_in_region, + s_credentials_provider_login_refresh_does_not_add_sign_in_region); + +static int s_check_host(const char *expected) { + ASSERT_BIN_ARRAYS_EQUALS( + expected, + strlen(expected), + credentials_provider_http_mock_tester.endpoint_host.buffer, + credentials_provider_http_mock_tester.endpoint_host.len); + return AWS_OP_SUCCESS; +} + +static int s_check_host_eu_west_1(const struct aws_json_value *written) { + (void)written; + return s_check_host("eu-west-1.signin.aws.amazon.com"); +} + +static int s_check_host_us_west_2(const struct aws_json_value *written) { + (void)written; + return s_check_host("us-west-2.signin.aws.amazon.com"); +} + +static int s_check_host_us_east_1(const struct aws_json_value *written) { + (void)written; + return s_check_host("us-east-1.signin.aws.amazon.com"); +} + +static int s_credentials_provider_login_refresh_uses_sign_in_region(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + /* the token's region wins over both the configured option and the profile */ + return s_refresh_and_check_token_file( + allocator, s_login_token_with_sign_in_region, aws_byte_cursor_from_c_str("us-west-2"), s_check_host_eu_west_1); +} +AWS_TEST_CASE( + credentials_provider_login_refresh_uses_sign_in_region, + s_credentials_provider_login_refresh_uses_sign_in_region); + +static int s_credentials_provider_login_refresh_falls_back_to_option_region( + struct aws_allocator *allocator, + void *ctx) { + (void)ctx; + return s_refresh_and_check_token_file( + allocator, s_login_token_good, aws_byte_cursor_from_c_str("us-west-2"), s_check_host_us_west_2); +} +AWS_TEST_CASE( + credentials_provider_login_refresh_falls_back_to_option_region, + s_credentials_provider_login_refresh_falls_back_to_option_region); + +static int s_credentials_provider_login_refresh_falls_back_to_profile_region( + struct aws_allocator *allocator, + void *ctx) { + (void)ctx; + return s_refresh_and_check_token_file( + allocator, s_login_token_good, (struct aws_byte_cursor){0}, s_check_host_us_east_1); +} +AWS_TEST_CASE( + credentials_provider_login_refresh_falls_back_to_profile_region, + s_credentials_provider_login_refresh_falls_back_to_profile_region); + static int s_credentials_provider_login_basic_success_after_failure(struct aws_allocator *allocator, void *ctx) { (void)ctx; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/credentials_provider_utils.c new/aws-c-auth-1.1.0/tests/credentials_provider_utils.c --- old/aws-c-auth-1.0.0/tests/credentials_provider_utils.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/credentials_provider_utils.c 2026-11-16 19:54:16.000000000 +0100 @@ -180,6 +180,11 @@ return NULL; } +size_t aws_credentials_provider_mock_get_call_count(struct aws_credentials_provider *provider) { + struct aws_credentials_provider_mock_impl *impl = provider->impl; + return impl->next_result; +} + /* * Mock async provider */ @@ -604,6 +609,7 @@ aws_array_list_clean_up(&credentials_provider_http_mock_tester.response_data_callbacks); aws_byte_buf_clean_up(&credentials_provider_http_mock_tester.request_path); aws_byte_buf_clean_up(&credentials_provider_http_mock_tester.request_body); + aws_byte_buf_clean_up(&credentials_provider_http_mock_tester.endpoint_host); aws_condition_variable_clean_up(&credentials_provider_http_mock_tester.signal); aws_mutex_clean_up(&credentials_provider_http_mock_tester.lock); aws_credentials_release(credentials_provider_http_mock_tester.credentials); @@ -648,6 +654,8 @@ mock_manager->allocator = allocator; mock_manager->shutdown_complete_callback = options->shutdown_complete_callback; mock_manager->shutdown_complete_user_data = options->shutdown_complete_user_data; + aws_byte_buf_clean_up(&credentials_provider_http_mock_tester.endpoint_host); + aws_byte_buf_init_copy_from_cursor(&credentials_provider_http_mock_tester.endpoint_host, allocator, options->host); return (struct aws_http_connection_manager *)mock_manager; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/credentials_provider_utils.h new/aws-c-auth-1.1.0/tests/credentials_provider_utils.h --- old/aws-c-auth-1.0.0/tests/credentials_provider_utils.h 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/credentials_provider_utils.h 2026-11-16 19:54:16.000000000 +0100 @@ -67,6 +67,9 @@ size_t result_count, struct aws_credentials_provider_shutdown_options *shutdown_options); +/* Number of get_credentials calls a synchronous mock has served */ +size_t aws_credentials_provider_mock_get_call_count(struct aws_credentials_provider *provider); + struct aws_credentials_provider *aws_credentials_provider_new_mock_async( struct aws_allocator *allocator, struct get_credentials_mock_result *results, @@ -116,6 +119,7 @@ struct aws_client_bootstrap *bootstrap; struct aws_byte_buf request_path; + struct aws_byte_buf endpoint_host; struct aws_byte_buf request_body; struct aws_http_make_request_options request_options; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/credentials_tests.c new/aws-c-auth-1.1.0/tests/credentials_tests.c --- old/aws-c-auth-1.0.0/tests/credentials_tests.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/credentials_tests.c 2026-11-16 19:54:16.000000000 +0100 @@ -1361,6 +1361,212 @@ AWS_TEST_CASE(credentials_provider_null_chain_test, s_credentials_provider_null_chain_test); +/* Builds a two-member chain from mocks; the caller keeps its references to the mocks */ +static struct aws_credentials_provider *s_new_two_member_chain( + struct aws_allocator *allocator, + struct aws_credentials_provider *provider1, + struct aws_credentials_provider *provider2, + bool pin_credential_provider) { + + struct aws_credentials_provider *providers[2] = {provider1, provider2}; + + struct aws_credentials_provider_chain_options options; + AWS_ZERO_STRUCT(options); + options.providers = providers; + options.provider_count = 2; + options.shutdown_options.shutdown_callback = s_on_shutdown_complete; + options.pin_credential_provider = pin_credential_provider; + + return aws_credentials_provider_new_chain(allocator, &options); +} + +/* Runs one get_credentials on a chain of synchronous mocks */ +static int s_get_chain_credentials_once( + struct aws_credentials_provider *chain, + struct aws_get_credentials_test_callback_result *callback_results) { + + ASSERT_SUCCESS(s_invoke_get_credentials(chain, callback_results, 1)); + ASSERT_SUCCESS(s_wait_for_get_credentials(callback_results)); + ASSERT_INT_EQUALS(1, callback_results->count); + return AWS_OP_SUCCESS; +} + +/* Pinned member is the only one asked later, and its failure is returned without fallback */ +static int s_credentials_provider_chain_pin_test(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + + s_aws_credentials_shutdown_checker_init(); + + struct aws_credentials *creds = aws_credentials_new_from_string( + allocator, s_access_key_id_2, s_secret_access_key_2, s_session_token_2, UINT64_MAX); + + /* Member 1 has one result, so asking it again would fail the test */ + struct get_credentials_mock_result results1[] = { + {.error_code = AWS_AUTH_CREDENTIALS_PROVIDER_STS_SOURCE_FAILURE, .credentials = NULL}, + }; + struct get_credentials_mock_result results2[] = { + {.error_code = 0, .credentials = creds}, + {.error_code = AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE, .credentials = NULL}, + }; + + struct aws_credentials_provider *mock1 = aws_credentials_provider_new_mock(allocator, results1, 1, NULL); + struct aws_credentials_provider *mock2 = aws_credentials_provider_new_mock(allocator, results2, 2, NULL); + struct aws_credentials_provider *chain = s_new_two_member_chain(allocator, mock1, mock2, true); + ASSERT_NOT_NULL(chain); + + struct aws_get_credentials_test_callback_result callback_results; + + /* First call walks past member 1 and pins member 2 */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NOT_NULL(callback_results.credentials); + ASSERT_CURSOR_VALUE_STRING_EQUALS( + aws_credentials_get_access_key_id(callback_results.credentials), s_access_key_id_2); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Second call asks only member 2 and returns its error */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NULL(callback_results.credentials); + ASSERT_INT_EQUALS(AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE, callback_results.last_error); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Member 1 was asked only on the first walk; member 2 served both calls */ + ASSERT_UINT_EQUALS(1, aws_credentials_provider_mock_get_call_count(mock1)); + ASSERT_UINT_EQUALS(2, aws_credentials_provider_mock_get_call_count(mock2)); + + aws_credentials_provider_release(mock1); + aws_credentials_provider_release(mock2); + aws_credentials_provider_release(chain); + s_aws_wait_for_provider_shutdown_callback(); + s_aws_credentials_shutdown_checker_clean_up(); + + aws_credentials_release(creds); + + return AWS_OP_SUCCESS; +} + +AWS_TEST_CASE(credentials_provider_chain_pin_test, s_credentials_provider_chain_pin_test); + +/* With the flag off, every call walks from the first member as before */ +static int s_credentials_provider_chain_pin_disabled_test(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + + s_aws_credentials_shutdown_checker_init(); + + struct aws_credentials *creds1 = aws_credentials_new_from_string( + allocator, s_access_key_id_1, s_secret_access_key_1, s_session_token_1, UINT64_MAX); + struct aws_credentials *creds2 = aws_credentials_new_from_string( + allocator, s_access_key_id_2, s_secret_access_key_2, s_session_token_2, UINT64_MAX); + + struct get_credentials_mock_result results1[] = { + {.error_code = AWS_AUTH_CREDENTIALS_PROVIDER_STS_SOURCE_FAILURE, .credentials = NULL}, + {.error_code = 0, .credentials = creds1}, + }; + struct get_credentials_mock_result results2[] = { + {.error_code = 0, .credentials = creds2}, + }; + + struct aws_credentials_provider *mock1 = aws_credentials_provider_new_mock(allocator, results1, 2, NULL); + struct aws_credentials_provider *mock2 = aws_credentials_provider_new_mock(allocator, results2, 1, NULL); + struct aws_credentials_provider *chain = s_new_two_member_chain(allocator, mock1, mock2, false); + ASSERT_NOT_NULL(chain); + + struct aws_get_credentials_test_callback_result callback_results; + + /* First call falls through to member 2 */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NOT_NULL(callback_results.credentials); + ASSERT_CURSOR_VALUE_STRING_EQUALS( + aws_credentials_get_access_key_id(callback_results.credentials), s_access_key_id_2); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Second call starts at member 1 again */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NOT_NULL(callback_results.credentials); + ASSERT_CURSOR_VALUE_STRING_EQUALS( + aws_credentials_get_access_key_id(callback_results.credentials), s_access_key_id_1); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Member 1 was asked on both walks; member 2 only on the first */ + ASSERT_UINT_EQUALS(2, aws_credentials_provider_mock_get_call_count(mock1)); + ASSERT_UINT_EQUALS(1, aws_credentials_provider_mock_get_call_count(mock2)); + + aws_credentials_provider_release(mock1); + aws_credentials_provider_release(mock2); + aws_credentials_provider_release(chain); + s_aws_wait_for_provider_shutdown_callback(); + s_aws_credentials_shutdown_checker_clean_up(); + + aws_credentials_release(creds2); + aws_credentials_release(creds1); + + return AWS_OP_SUCCESS; +} + +AWS_TEST_CASE(credentials_provider_chain_pin_disabled_test, s_credentials_provider_chain_pin_disabled_test); + +/* When every member fails nothing is pinned, the last error is returned and the next call walks again */ +static int s_credentials_provider_chain_pin_all_fail_test(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + + s_aws_credentials_shutdown_checker_init(); + + struct aws_credentials *creds1 = aws_credentials_new_from_string( + allocator, s_access_key_id_1, s_secret_access_key_1, s_session_token_1, UINT64_MAX); + + struct get_credentials_mock_result results1[] = { + {.error_code = AWS_AUTH_CREDENTIALS_PROVIDER_STS_SOURCE_FAILURE, .credentials = NULL}, + {.error_code = 0, .credentials = creds1}, + {.error_code = 0, .credentials = creds1}, + }; + /* Member 2 has one result, so asking it after member 1 is pinned would fail the test */ + struct get_credentials_mock_result results2[] = { + {.error_code = AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE, .credentials = NULL}, + }; + + struct aws_credentials_provider *mock1 = aws_credentials_provider_new_mock(allocator, results1, 3, NULL); + struct aws_credentials_provider *mock2 = aws_credentials_provider_new_mock(allocator, results2, 1, NULL); + struct aws_credentials_provider *chain = s_new_two_member_chain(allocator, mock1, mock2, true); + ASSERT_NOT_NULL(chain); + + struct aws_get_credentials_test_callback_result callback_results; + + /* First call: both members fail, the last member's error is returned */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NULL(callback_results.credentials); + ASSERT_INT_EQUALS(AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE, callback_results.last_error); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Second call walks from member 1, which succeeds and is pinned */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NOT_NULL(callback_results.credentials); + ASSERT_CURSOR_VALUE_STRING_EQUALS( + aws_credentials_get_access_key_id(callback_results.credentials), s_access_key_id_1); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Third call goes only to pinned member 1 */ + ASSERT_SUCCESS(s_get_chain_credentials_once(chain, &callback_results)); + ASSERT_NOT_NULL(callback_results.credentials); + ASSERT_CURSOR_VALUE_STRING_EQUALS( + aws_credentials_get_access_key_id(callback_results.credentials), s_access_key_id_1); + aws_get_credentials_test_callback_result_clean_up(&callback_results); + + /* Member 1 served all three calls; member 2 was asked only on the failed walk */ + ASSERT_UINT_EQUALS(3, aws_credentials_provider_mock_get_call_count(mock1)); + ASSERT_UINT_EQUALS(1, aws_credentials_provider_mock_get_call_count(mock2)); + + aws_credentials_provider_release(mock1); + aws_credentials_provider_release(mock2); + aws_credentials_provider_release(chain); + s_aws_wait_for_provider_shutdown_callback(); + s_aws_credentials_shutdown_checker_clean_up(); + + aws_credentials_release(creds1); + + return AWS_OP_SUCCESS; +} + +AWS_TEST_CASE(credentials_provider_chain_pin_all_fail_test, s_credentials_provider_chain_pin_all_fail_test); + static int s_credentials_provider_default_test(struct aws_allocator *allocator, bool manual_tls) { aws_auth_library_init(allocator); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-auth-1.0.0/tests/credentials_utils_tests.c new/aws-c-auth-1.1.0/tests/credentials_utils_tests.c --- old/aws-c-auth-1.0.0/tests/credentials_utils_tests.c 2026-08-26 01:40:29.000000000 +0200 +++ new/aws-c-auth-1.1.0/tests/credentials_utils_tests.c 2026-11-16 19:54:16.000000000 +0100 @@ -29,6 +29,13 @@ aws_string_destroy(endpoint); aws_string_destroy(region); + region = aws_string_new_from_c_str(allocator, "eusc-de-east-1"); + ASSERT_SUCCESS(aws_credentials_provider_construct_endpoint( + allocator, &endpoint, region, service_name, service_name, service_name, NULL, NULL, NULL, false)); + ASSERT_STR_EQUALS("sts.eusc-de-east-1.amazonaws.eu", aws_string_c_str(endpoint)); + aws_string_destroy(endpoint); + aws_string_destroy(region); + region = aws_string_new_from_c_str(allocator, "us-iso-east-1"); ASSERT_SUCCESS(aws_credentials_provider_construct_endpoint( allocator, &endpoint, region, service_name, service_name, service_name, NULL, NULL, NULL, false));
