Skip to content

Commit 37ebf2d

Browse files
azkrishpyTingDaoK
andauthored
Add proxy config for credential providers (#281)
Co-authored-by: Dengke Tang <[email protected]> Co-authored-by: Krish <>
1 parent 7d6cfb9 commit 37ebf2d

21 files changed

+444
-2
lines changed

include/aws/auth/aws_imds_client.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ struct aws_imds_client_options {
4343
*/
4444
struct aws_retry_strategy *retry_strategy;
4545

46+
/*
47+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
48+
* aws_http_credentials_provider.h for more information.
49+
*/
50+
const struct proxy_env_var_settings *proxy_ev_settings;
51+
4652
/*
4753
* What version of the imds protocol to use
4854
*

include/aws/auth/credentials.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/common/array_list.h>
1111
#include <aws/common/atomics.h>
1212
#include <aws/common/linked_list.h>
13+
#include <aws/http/proxy.h>
1314
#include <aws/io/io.h>
1415

1516
AWS_PUSH_SANE_WARNING_LEVEL
@@ -224,6 +225,12 @@ struct aws_credentials_provider_imds_options {
224225

225226
/* For mocking the http layer in tests, leave NULL otherwise */
226227
struct aws_auth_http_system_vtable *function_table;
228+
229+
/*
230+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
231+
* aws_http_credentials_provider.h for more information.
232+
*/
233+
const struct proxy_env_var_settings *proxy_ev_settings;
227234
};
228235

229236
/*
@@ -259,6 +266,12 @@ struct aws_credentials_provider_ecs_environment_options {
259266
*/
260267
struct aws_tls_ctx *tls_ctx;
261268

269+
/*
270+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
271+
* aws_http_credentials_provider.h for more information.
272+
*/
273+
const struct proxy_env_var_settings *proxy_ev_settings;
274+
262275
/* For mocking the http layer in tests, leave NULL otherwise */
263276
struct aws_auth_http_system_vtable *function_table;
264277
};
@@ -310,6 +323,12 @@ struct aws_credentials_provider_ecs_options {
310323
*/
311324
struct aws_tls_ctx *tls_ctx;
312325

326+
/*
327+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
328+
* aws_http_credentials_provider.h for more information.
329+
*/
330+
const struct proxy_env_var_settings *proxy_ev_settings;
331+
313332
/* For mocking the http layer in tests, leave NULL otherwise */
314333
struct aws_auth_http_system_vtable *function_table;
315334

@@ -354,6 +373,12 @@ struct aws_credentials_provider_x509_options {
354373
*/
355374
const struct aws_http_proxy_options *proxy_options;
356375

376+
/**
377+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
378+
* aws_http_credentials_provider.h for more information.
379+
*/
380+
const struct proxy_env_var_settings *proxy_ev_settings;
381+
357382
/* For mocking the http layer in tests, leave NULL otherwise */
358383
struct aws_auth_http_system_vtable *function_table;
359384
};
@@ -401,6 +426,12 @@ struct aws_credentials_provider_sts_web_identity_options {
401426
*/
402427
struct aws_tls_ctx *tls_ctx;
403428

429+
/*
430+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
431+
* aws_http_credentials_provider.h for more information.
432+
*/
433+
const struct proxy_env_var_settings *proxy_ev_settings;
434+
404435
/* For mocking the http layer in tests, leave NULL otherwise */
405436
struct aws_auth_http_system_vtable *function_table;
406437

@@ -470,6 +501,12 @@ struct aws_credentials_provider_sso_options {
470501
*/
471502
struct aws_tls_ctx *tls_ctx;
472503

504+
/*
505+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
506+
* aws_http_credentials_provider.h for more information.
507+
*/
508+
const struct proxy_env_var_settings *proxy_ev_settings;
509+
473510
/* For mocking, leave NULL otherwise */
474511
struct aws_auth_http_system_vtable *function_table;
475512
aws_io_clock_fn *system_clock_fn;
@@ -525,6 +562,12 @@ struct aws_credentials_provider_sts_options {
525562
*/
526563
const struct aws_http_proxy_options *http_proxy_options;
527564

565+
/**
566+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
567+
* aws_http_credentials_provider.h for more information.
568+
*/
569+
const struct proxy_env_var_settings *proxy_ev_settings;
570+
528571
/**
529572
* (Optional)
530573
* Uses a cached config file profile collection (~/.aws/config). You can also pass a merged profile collection,
@@ -628,6 +671,12 @@ struct aws_credentials_provider_chain_default_options {
628671
* If enabled, the Environment Credentials Provider is not added to the chain.
629672
*/
630673
bool skip_environment_credentials_provider;
674+
675+
/*
676+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
677+
* aws_http_credentials_provider.h for more information.
678+
*/
679+
const struct proxy_env_var_settings *proxy_ev_settings;
631680
};
632681

633682
typedef int(aws_credentials_provider_delegate_get_credentials_fn)(
@@ -722,6 +771,12 @@ struct aws_credentials_provider_cognito_options {
722771
*/
723772
const struct aws_http_proxy_options *http_proxy_options;
724773

774+
/**
775+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
776+
* aws_http_credentials_provider.h for more information.
777+
*/
778+
const struct proxy_env_var_settings *proxy_ev_settings;
779+
725780
/* For mocking the http layer in tests, leave NULL otherwise */
726781
struct aws_auth_http_system_vtable *function_table;
727782

@@ -795,6 +850,12 @@ struct aws_credentials_provider_login_options {
795850
*/
796851
struct aws_tls_ctx *tls_ctx;
797852

853+
/*
854+
* (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
855+
* aws_http_credentials_provider.h for more information.
856+
*/
857+
const struct proxy_env_var_settings *proxy_ev_settings;
858+
798859
/* For mocking, leave NULL otherwise */
799860
struct aws_auth_http_system_vtable *function_table;
800861
aws_io_clock_fn *system_clock_fn;

include/aws/auth/private/aws_http_credentials_provider.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ struct aws_credentials_provider_http_options {
5050
*/
5151
struct aws_retry_strategy *retry_strategy;
5252

53+
/*
54+
* Optional.
55+
* Configuration for fetching proxy configuration from environment for http connections.
56+
* By Default proxy_ev_settings.aws_http_proxy_env_var_type is set to AWS_HPEV_DISABLE which means we don't read
57+
* proxy configuration from environment. If proxy_options exist for a particular credential provider and is set by
58+
* the user, it overrides what is set from the environment.
59+
*/
60+
const struct proxy_env_var_settings *proxy_ev_settings;
61+
5362
/* For mocking the http layer in tests, leave NULL otherwise */
5463
const struct aws_auth_http_system_vtable *function_table;
5564
};

source/aws_http_credentials_provider.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ int aws_http_credentials_provider_init_base(
419419
manager_options.shutdown_complete_callback = s_on_connection_manager_shutdown;
420420
manager_options.shutdown_complete_user_data = provider;
421421
manager_options.tls_connection_options = &tls_connection_options;
422+
manager_options.proxy_ev_settings = options->proxy_ev_settings;
422423

423424
impl->function_table = options->function_table;
424425
if (impl->function_table == NULL) {

source/aws_imds_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct aws_imds_client *aws_imds_client_new(
168168
manager_options.max_connections = 10;
169169
manager_options.shutdown_complete_callback = s_on_connection_manager_shutdown;
170170
manager_options.shutdown_complete_user_data = client;
171+
manager_options.proxy_ev_settings = options->proxy_ev_settings;
171172

172173
client->connection_manager = client->function_table->aws_http_connection_manager_new(allocator, &manager_options);
173174
if (!client->connection_manager) {

source/credentials_provider_cognito.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_cognito(
817817
manager_options.shutdown_complete_user_data = provider;
818818
manager_options.tls_connection_options = &tls_connection_options;
819819
manager_options.proxy_options = options->http_proxy_options;
820+
manager_options.proxy_ev_settings = options->proxy_ev_settings;
820821

821822
impl->function_table = options->function_table;
822823
if (impl->function_table == NULL) {

source/credentials_provider_default_chain.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ static struct aws_credentials_provider *s_aws_credentials_provider_new_ecs_or_im
3535
struct aws_allocator *allocator,
3636
const struct aws_credentials_provider_shutdown_options *shutdown_options,
3737
struct aws_client_bootstrap *bootstrap,
38-
struct aws_tls_ctx *tls_ctx) {
38+
struct aws_tls_ctx *tls_ctx,
39+
const struct proxy_env_var_settings *proxy_ev_settings) {
3940

4041
/* Try to create the ECS provider. This will fail if its environment variables aren't set */
4142
struct aws_credentials_provider_ecs_environment_options ecs_options = {
4243
.shutdown_options = *shutdown_options,
4344
.bootstrap = bootstrap,
4445
.tls_ctx = tls_ctx,
46+
.proxy_ev_settings = proxy_ev_settings,
4547
};
4648
struct aws_credentials_provider *ecs_provider =
4749
aws_credentials_provider_new_ecs_from_environment(allocator, &ecs_options);
@@ -64,6 +66,7 @@ static struct aws_credentials_provider *s_aws_credentials_provider_new_ecs_or_im
6466
struct aws_credentials_provider_imds_options imds_options = {
6567
.shutdown_options = *shutdown_options,
6668
.bootstrap = bootstrap,
69+
.proxy_ev_settings = proxy_ev_settings,
6770
};
6871
return aws_credentials_provider_new_imds(allocator, &imds_options);
6972
}
@@ -301,6 +304,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_chain_default(
301304
sts_options.shutdown_options = sub_provider_shutdown_options;
302305
sts_options.config_profile_collection_cached = options->profile_collection_cached;
303306
sts_options.profile_name_override = options->profile_name_override;
307+
sts_options.proxy_ev_settings = options->proxy_ev_settings;
304308
sts_provider = aws_credentials_provider_new_sts_web_identity(allocator, &sts_options);
305309
if (sts_provider != NULL) {
306310
providers[index++] = sts_provider;
@@ -311,7 +315,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_chain_default(
311315
/* Providers that will always make a network call unless explicitly disabled... */
312316

313317
ecs_or_imds_provider = s_aws_credentials_provider_new_ecs_or_imds(
314-
allocator, &sub_provider_shutdown_options, options->bootstrap, tls_ctx);
318+
allocator, &sub_provider_shutdown_options, options->bootstrap, tls_ctx, options->proxy_ev_settings);
315319
if (ecs_or_imds_provider != NULL) {
316320
providers[index++] = ecs_or_imds_provider;
317321
/* 1 shutdown call from the imds or ecs provider's shutdown */

source/credentials_provider_ecs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_ecs(
799799
manager_options.shutdown_complete_callback = s_on_connection_manager_shutdown;
800800
manager_options.shutdown_complete_user_data = provider;
801801
manager_options.tls_connection_options = options->tls_ctx ? &tls_connection_options : NULL;
802+
manager_options.proxy_ev_settings = options->proxy_ev_settings;
802803

803804
impl->function_table = options->function_table;
804805
if (impl->function_table == NULL) {
@@ -869,6 +870,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_ecs_from_environme
869870
.shutdown_options = options->shutdown_options,
870871
.bootstrap = options->bootstrap,
871872
.function_table = options->function_table,
873+
.proxy_ev_settings = options->proxy_ev_settings,
872874
};
873875

874876
struct aws_string *ecs_env_token_file_path = NULL;

source/credentials_provider_imds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_imds(
9090
.shutdown_callback = s_on_imds_client_shutdown,
9191
.shutdown_user_data = provider,
9292
},
93+
.proxy_ev_settings = options->proxy_ev_settings,
9394
};
9495

9596
impl->client = aws_imds_client_new(allocator, &client_options);

source/credentials_provider_login.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_login(
463463
http_options.function_table = options->function_table;
464464
http_options.endpoint = aws_byte_cursor_from_string(parameters->endpoint);
465465
http_options.max_connections = 2;
466+
http_options.proxy_ev_settings = options->proxy_ev_settings;
466467

467468
login_user_data->parameters = parameters;
468469
login_user_data->request_vtable = &s_login_request_vtable;

0 commit comments

Comments
 (0)