Debian Codegraph @

crt/aws-c-auth/include/aws/auth/credentials.h

raw symbols SCIP
1 #ifndef AWS_AUTH_CREDENTIALS_H
2 #define AWS_AUTH_CREDENTIALS_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8
9 #include <aws/auth/auth.h>
10 #include <aws/common/array_list.h>
11 #include <aws/common/atomics.h>
12 #include <aws/common/linked_list.h>
13 #include <aws/http/proxy.h>
14 #include <aws/io/io.h>
15
16 AWS_PUSH_SANE_WARNING_LEVEL
17
18 struct aws_client_bootstrap;
19 struct aws_auth_http_system_vtable;
20 struct aws_credentials;
21 struct aws_credentials_provider;
22 struct aws_ecc_key_pair;
23 struct aws_string;
24
25 extern const uint16_t aws_sts_assume_role_default_duration_secs;
26
27 /*
28 * Signature for the credentials sourcing callback
29 */
30 typedef void(aws_on_get_credentials_callback_fn)(struct aws_credentials *credentials, int error_code, void *user_data);
31
32 typedef int(aws_credentials_provider_get_credentials_fn)(
33 struct aws_credentials_provider *provider,
34 aws_on_get_credentials_callback_fn callback,
35 void *user_data);
36 typedef void(aws_credentials_provider_destroy_fn)(struct aws_credentials_provider *provider);
37
38 /*
39 * Common function table that all credentials provider implementations must support
40 */
41 struct aws_credentials_provider_vtable {
42 aws_credentials_provider_get_credentials_fn *get_credentials;
43 aws_credentials_provider_destroy_fn *destroy;
44 };
45
46 typedef void(aws_credentials_provider_shutdown_completed_fn)(void *user_data);
47
48 /*
49 * All credentials providers support an optional shutdown callback that
50 * gets invoked, with appropriate user data, when the resources used by the provider
51 * are no longer in use. For example, the imds provider uses this to
52 * signal when it is no longer using the client bootstrap used in its
53 * internal connection manager.
54 */
55 struct aws_credentials_provider_shutdown_options {
56 aws_credentials_provider_shutdown_completed_fn *shutdown_callback;
57 void *shutdown_user_data;
58 };
59
60 /**
61 * A baseclass for credentials providers. A credentials provider is an object that has an asynchronous
62 * query function for retrieving AWS credentials.
63 *
64 * Ref-counted. Thread-safe.
65 */
66 struct aws_credentials_provider {
67 struct aws_credentials_provider_vtable *vtable;
68 struct aws_allocator *allocator;
69 struct aws_credentials_provider_shutdown_options shutdown_options;
70 void *impl;
71 struct aws_atomic_var ref_count;
72 };
73
74 /*
75 * Config structs for creating all the different credentials providers
76 */
77
78 /**
79 * Configuration options for a provider that returns a fixed set of credentials
80 */
81 struct aws_credentials_provider_static_options {
82 struct aws_credentials_provider_shutdown_options shutdown_options;
83 struct aws_byte_cursor access_key_id;
84 struct aws_byte_cursor secret_access_key;
85 struct aws_byte_cursor session_token;
86 struct aws_byte_cursor account_id;
87 };
88
89 /**
90 * Configuration options for a provider that returns credentials based on environment variable values
91 */
92 struct aws_credentials_provider_environment_options {
93 struct aws_credentials_provider_shutdown_options shutdown_options;
94 };
95
96 /**
97 * Configuration options for a provider that sources credentials from the aws config and credentials files
98 * (by default ~/.aws/config and ~/.aws/credentials)
99 */
100 struct aws_credentials_provider_profile_options {
101 struct aws_credentials_provider_shutdown_options shutdown_options;
102
103 /*
104 * Override of what profile to use to source credentials from ('default' by default)
105 */
106 struct aws_byte_cursor profile_name_override;
107
108 /*
109 * Override path to the profile config file (~/.aws/config by default)
110 */
111 struct aws_byte_cursor config_file_name_override;
112
113 /*
114 * Override path to the profile credentials file (~/.aws/credentials by default)
115 */
116 struct aws_byte_cursor credentials_file_name_override;
117
118 /**
119 * (Optional)
120 * Use a cached merged profile collection. A merge collection has both config file
121 * (~/.aws/config) and credentials file based profile collection (~/.aws/credentials) using
122 * `aws_profile_collection_new_from_merge`.
123 * If this option is provided, `config_file_name_override` and `credentials_file_name_override` will be ignored.
124 */
125 struct aws_profile_collection *profile_collection_cached;
126
127 /*
128 * Bootstrap to use for any network connections made while sourcing credentials (for example,
129 * a profile that uses assume-role will need to hit STS)
130 */
131 struct aws_client_bootstrap *bootstrap;
132
133 /*
134 * Client TLS context to use for any secure network connections made while sourcing credentials
135 * (for example, a profile that uses assume-role will need to hit STS).
136 *
137 * If a TLS context is needed, and you did not pass one in, it will be created automatically.
138 * However, you are encouraged to pass in a shared one since these are expensive objects.
139 * If using BYO_CRYPTO, you must provide the TLS context since it cannot be created automatically.
140 */
141 struct aws_tls_ctx *tls_ctx;
142
143 /* For mocking the http layer in tests, leave NULL otherwise */
144 struct aws_auth_http_system_vtable *function_table;
145
146 /* Add proxy options for sts based provider */
147 struct proxy_env_var_settings *proxy_ev_settings;
148 };
149
150 /**
151 * Configuration options for a provider that functions as a caching decorator. Credentials sourced through this
152 * provider will be cached within it until their expiration time. When the cached credentials expire, new
153 * credentials will be fetched when next queried.
154 */
155 struct aws_credentials_provider_cached_options {
156 struct aws_credentials_provider_shutdown_options shutdown_options;
157
158 /*
159 * The provider to cache credentials query results from
160 */
161 struct aws_credentials_provider *source;
162
163 /*
164 * An optional expiration time period for sourced credentials. For a given set of cached credentials,
165 * the refresh time period will be the minimum of this time and any expiration timestamp on the credentials
166 * themselves.
167 */
168 uint64_t refresh_time_in_milliseconds;
169
170 /* For mocking, leave NULL otherwise */
171 aws_io_clock_fn *high_res_clock_fn;
172 aws_io_clock_fn *system_clock_fn;
173 };
174
175 /**
176 * Configuration options for a provider that queries, in order, a list of providers. This provider uses the
177 * first set of credentials successfully queried. Providers are queried one at a time; a provider is not queried
178 * until the preceding provider has failed to source credentials.
179 */
180 struct aws_credentials_provider_chain_options {
181 struct aws_credentials_provider_shutdown_options shutdown_options;
182
183 /*
184 * Pointer to an array of credentials providers to use
185 */
186 struct aws_credentials_provider **providers;
187
188 /*
189 * Number of elements in the array of credentials providers
190 */
191 size_t provider_count;
192 };
193
194 /*
195 * EC2 IMDS_V1 takes one http request to get resource, while IMDS_V2 takes one more token (Http PUT) request
196 * to get secure token used in following request.
197 */
198 enum aws_imds_protocol_version {
199 /**
200 * Defaults to IMDS_PROTOCOL_V2. It can be set to either one and IMDS Client
201 * will figure out (by looking at response code) which protocol an instance
202 * is using. But a more clear setting will reduce unnecessary network request.
203 */
204 IMDS_PROTOCOL_V2,
205 IMDS_PROTOCOL_V1,
206 };
207
208 /**
209 * IP address mode for IMDS connections
210 */
211 enum aws_imds_endpoint_mode {
212 /* Use default behavior (IPv4), or check environment variable if not explicitly set */
213 AWS_IMDS_ENDPOINT_MODE_DEFAULT = 0,
214 /* Explicitly use IPv4 */
215 AWS_IMDS_ENDPOINT_MODE_IPV4,
216 /* Explicitly use IPv6 */
217 AWS_IMDS_ENDPOINT_MODE_IPV6,
218 };
219
220 /**
221 * Configuration options for the provider that sources credentials from ec2 instance metadata
222 */
223 struct aws_credentials_provider_imds_options {
224 struct aws_credentials_provider_shutdown_options shutdown_options;
225
226 /*
227 * Connection bootstrap to use for any network connections made while sourcing credentials
228 */
229 struct aws_client_bootstrap *bootstrap;
230
231 /*
232 * Which version of the imds query protocol to use.
233 */
234 enum aws_imds_protocol_version imds_version;
235
236 /*
237 * If true, fallback from v2 to v1 will be disabled for all cases
238 */
239 bool ec2_metadata_v1_disabled;
240
241 /* For mocking the http layer in tests, leave NULL otherwise */
242 struct aws_auth_http_system_vtable *function_table;
243
244 /*
245 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
246 * aws_http_credentials_provider.h for more information.
247 */
248 const struct proxy_env_var_settings *proxy_ev_settings;
249
250 /*
251 * (Optional) Override the default IMDS endpoint.
252 * If this cursor is empty (ptr == NULL or len == 0), the endpoint will be determined by:
253 * 1. AWS_EC2_METADATA_SERVICE_ENDPOINT environment variable (if set)
254 * 2. Default endpoint based on imds_endpoint_mode (IPv4: "http://169.254.169.254", IPv6: "http://[fd00:ec2::254]")
255 *
256 * Should be a valid URI string. Supports both HTTP and HTTPS schemes:
257 * - HTTP: Uses default port 80 if not specified
258 * - HTTPS: Uses default port 443 if not specified, with automatic TLS configuration
259 * HTTPS connections use default client TLS settings with SNI hostname set automatically.
260 * Example: aws_byte_cursor_from_c_str("http://127.0.0.1:8080")
261 */
262 struct aws_byte_cursor imds_endpoint;
263
264 /*
265 * (Optional) IP address mode for IMDS connections.
266 * If set to AWS_IMDS_ENDPOINT_MODE_DEFAULT (0), the mode will be determined by:
267 * 1. AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE environment variable (if set to "IPv4" or "IPv6")
268 * 2. Default mode (IPv4)
269 *
270 * AWS_IMDS_ENDPOINT_MODE_DEFAULT (0) - Use environment variable or default to IPv4
271 * AWS_IMDS_ENDPOINT_MODE_IPV4 - Explicitly use IPv4
272 * AWS_IMDS_ENDPOINT_MODE_IPV6 - Explicitly use IPv6
273 */
274 enum aws_imds_endpoint_mode imds_endpoint_mode;
275 };
276
277 /*
278 * Configuration options for the provider that sources credentials from ECS container metadata.
279 * The ECS creds provider can be used to access creds via either a relative URI to a fixed endpoint
280 * (http://169.254.170.2) or via a full URI specified by environment variables (in order of priority):
281 * AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
282 * AWS_CONTAINER_CREDENTIALS_FULL_URI
283 *
284 *`AWS_CONTAINER_CREDENTIALS_FULL_URI` URL must satisfy one of the following:
285 * 1. The URL begins with `https`.
286 * 2. The resolved IP address is within the loopback CIDR (IPv4 127.0.0.0/8, IPv6 ::1/128), ECS container address
287 * (169.254.170.2), or EKS Pod Identity address (169.254.170.23 or fd00:ec2::23).
288 *
289 * For the Authorization token, there are two ways (in order of priority):
290 * 1. AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE (an env var which contains the absolute path to the token file. The file
291 * will be re-read for each call to get credentials.)
292 * 2. AWS_CONTAINER_AUTHORIZATION_TOKEN (an env var that contains a static auth token)
293 */
294 struct aws_credentials_provider_ecs_environment_options {
295 struct aws_credentials_provider_shutdown_options shutdown_options;
296
297 /*
298 * (Required)
299 * Connection bootstrap to use for any network connections made while sourcing credentials
300 */
301 struct aws_client_bootstrap *bootstrap;
302
303 /*
304 * (Required)
305 * Client TLS context to use when making a query. This will only be used if the AWS_CONTAINER_CREDENTIALS_FULL_URI
306 * is set and starts with https
307 */
308 struct aws_tls_ctx *tls_ctx;
309
310 /*
311 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
312 * aws_http_credentials_provider.h for more information.
313 */
314 const struct proxy_env_var_settings *proxy_ev_settings;
315
316 /* For mocking the http layer in tests, leave NULL otherwise */
317 struct aws_auth_http_system_vtable *function_table;
318 };
319
320 /*
321 * Configuration options for the provider that sources credentials from ECS container metadata.
322 * This options struct doesn't read anything from the environment and requires everything to be explicitly passed in. If
323 * you need to read properties from the environment, use the `aws_credentials_provider_ecs_environment_options`.
324 *
325 *`host` must satisfy one of the following:
326 * 1. tls_context is set
327 * 2. The resolved IP address is within the loopback CIDR (IPv4 127.0.0.0/8, IPv6 ::1/128), ECS container address
328 * (169.254.170.2), or EKS Pod Identity address (169.254.170.23 or fd00:ec2::23).
329 */
330 struct aws_credentials_provider_ecs_options {
331 struct aws_credentials_provider_shutdown_options shutdown_options;
332
333 /*
334 * Connection bootstrap to use for any network connections made while sourcing credentials
335 */
336 struct aws_client_bootstrap *bootstrap;
337
338 /*
339 * Host to query credentials from
340 */
341 struct aws_byte_cursor host;
342
343 /*
344 * Http path and query string for the credentials query
345 */
346 struct aws_byte_cursor path_and_query;
347
348 /*
349 * Authorization token file path to include in the credentials query. The file will be re-read for each call to
350 * get_credentials.
351 * This has higher priority than `auth_token`.
352 */
353 struct aws_byte_cursor auth_token_file_path;
354
355 /*
356 * Authorization token to include in the credentials query.
357 * No effect if `auth_token_file_path` is set.
358 */
359 struct aws_byte_cursor auth_token;
360
361 /*
362 * Client TLS context to use when making query.
363 * If set, port 443 is used. If NULL, port 80 is used.
364 */
365 struct aws_tls_ctx *tls_ctx;
366
367 /*
368 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
369 * aws_http_credentials_provider.h for more information.
370 */
371 const struct proxy_env_var_settings *proxy_ev_settings;
372
373 /* For mocking the http layer in tests, leave NULL otherwise */
374 struct aws_auth_http_system_vtable *function_table;
375
376 /*
377 * Port to query credentials from. If zero, 80/443 will be used based on whether or not tls is enabled.
378 */
379 uint32_t port;
380 };
381
382 /**
383 * Configuration options for the X509 credentials provider
384 *
385 * The x509 credentials provider sources temporary credentials from AWS IoT Core using TLS mutual authentication.
386 * See details: https://docs.aws.amazon.com/iot/latest/developerguide/authorizing-direct-aws.html
387 * An end to end demo with detailed steps can be found here:
388 * https://aws.amazon.com/blogs/security/how-to-eliminate-the-need-for-hardcoded-aws-credentials-in-devices-by-using-the-aws-iot-credentials-provider/
389 */
390 struct aws_credentials_provider_x509_options {
391 struct aws_credentials_provider_shutdown_options shutdown_options;
392
393 /*
394 * Connection bootstrap to use for any network connections made while sourcing credentials
395 */
396 struct aws_client_bootstrap *bootstrap;
397
398 /* TLS connection options that have been initialized with your x509 certificate and private key */
399 const struct aws_tls_connection_options *tls_connection_options;
400
401 /* IoT thing name you registered with AWS IOT for your device, it will be used in http request header */
402 struct aws_byte_cursor thing_name;
403
404 /* Iot role alias you created with AWS IoT for your IAM role, it will be used in http request path */
405 struct aws_byte_cursor role_alias;
406
407 /**
408 * Per-account X509 credentials sourcing endpoint.
409 */
410 struct aws_byte_cursor endpoint;
411
412 /**
413 * (Optional) Http proxy configuration for the http request that fetches credentials
414 */
415 const struct aws_http_proxy_options *proxy_options;
416
417 /**
418 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
419 * aws_http_credentials_provider.h for more information.
420 */
421 const struct proxy_env_var_settings *proxy_ev_settings;
422
423 /* For mocking the http layer in tests, leave NULL otherwise */
424 struct aws_auth_http_system_vtable *function_table;
425 };
426
427 /**
428 * Configuration options for the STS web identity provider
429 *
430 * Sts with web identity credentials provider sources a set of temporary security credentials for users who have been
431 * authenticated in a mobile or web application with a web identity provider.
432 * Example providers include Amazon Cognito, Login with Amazon, Facebook, Google, or any OpenID Connect-compatible
433 * identity provider like Elastic Kubernetes Service
434 * https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html
435 * The required parameters used in the request (region, roleArn, sessionName, tokenFilePath) are automatically resolved
436 * by SDK from envrionment variables or config file if not set.
437 ---------------------------------------------------------------------------------
438 | Parameter | Environment Variable Name | Config File Property Name |
439 ----------------------------------------------------------------------------------
440 | region | AWS_REGION/AWS_DEFAULT_REGION| region |
441 | role_arn | AWS_ROLE_ARN | role_arn |
442 | role_session_name | AWS_ROLE_SESSION_NAME | role_session_name |
443 | token_file_path | AWS_WEB_IDENTITY_TOKEN_FILE | web_identity_token_file |
444 |--------------------------------------------------------------------------------|
445 * The order of resolution is the following
446 * 1. Parameters
447 * 2. Environment Variables (in case of region, the AWS_REGION is preferred over the AWS_DEFAULT_REGION)
448 * 3. Config File
449 */
450 struct aws_credentials_provider_sts_web_identity_options {
451 struct aws_credentials_provider_shutdown_options shutdown_options;
452
453 /*
454 * Connection bootstrap to use for any network connections made while sourcing credentials
455 */
456 struct aws_client_bootstrap *bootstrap;
457
458 /**
459 * (Optional)
460 * Use a cached config profile collection. You can also pass a merged collection.
461 */
462 struct aws_profile_collection *config_profile_collection_cached;
463
464 /*
465 * Client TLS context to use when querying STS web identity provider.
466 * Required.
467 */
468 struct aws_tls_ctx *tls_ctx;
469
470 /*
471 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
472 * aws_http_credentials_provider.h for more information.
473 */
474 const struct proxy_env_var_settings *proxy_ev_settings;
475
476 /* For mocking the http layer in tests, leave NULL otherwise */
477 struct aws_auth_http_system_vtable *function_table;
478
479 /*
480 * (Optional)
481 * Override of what profile to use, if not set, 'default' will be used.
482 */
483 struct aws_byte_cursor profile_name_override;
484
485 /*
486 * (Optional)
487 * Override of region, if not set, it will be resolved from env or profile.
488 */
489 struct aws_byte_cursor region;
490 /*
491 * (Optional)
492 * Override of role_arn, if not set, it will be resolved from env or profile.
493 */
494 struct aws_byte_cursor role_arn;
495 /*
496 * (Optional)
497 * Override of role_session_name, if not set, it will be resolved from env or profile.
498 */
499 struct aws_byte_cursor role_session_name;
500 /*
501 * (Optional)
502 * Override of token_file_path, if not set, it will be resolved from env or profile.
503 */
504 struct aws_byte_cursor token_file_path;
505 };
506
507 /*
508 * Configuration for the SSOCredentialsProvider that sends a GetRoleCredentialsRequest to the AWS Single
509 * Sign-On Service to maintain short-lived sessions to use for authentication.
510 *
511 * https://docs.aws.amazon.com/sdkref/latest/guide/feature-sso-credentials.html
512 */
513 struct aws_credentials_provider_sso_options {
514 struct aws_credentials_provider_shutdown_options shutdown_options;
515
516 /*
517 * Override of what profile to use to source credentials from ('default' by default)
518 */
519 struct aws_byte_cursor profile_name_override;
520
521 /*
522 * Override path to the profile config file (~/.aws/config by default)
523 */
524 struct aws_byte_cursor config_file_name_override;
525
526 /**
527 * (Optional)
528 * Use a cached config profile collection. You can also pass a merged collection.
529 * config_file_name_override will be ignored if this option is provided.
530 */
531 struct aws_profile_collection *config_file_cached;
532
533 /*
534 * Connection bootstrap to use for any network connections made while sourcing credentials
535 * Required.
536 */
537 struct aws_client_bootstrap *bootstrap;
538
539 /*
540 * Client TLS context to use when querying SSO provider.
541 * Required.
542 */
543 struct aws_tls_ctx *tls_ctx;
544
545 /*
546 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
547 * aws_http_credentials_provider.h for more information.
548 */
549 const struct proxy_env_var_settings *proxy_ev_settings;
550
551 /* For mocking, leave NULL otherwise */
552 struct aws_auth_http_system_vtable *function_table;
553 aws_io_clock_fn *system_clock_fn;
554 };
555
556 /**
557 * Configuration options for the STS credentials provider.
558 * STS Credentials Provider will try to automatically resolve the region and use a regional STS endpoint if successful.
559 * The region resolution order is the following:
560 * 1. AWS_REGION environment variable
561 * 2. AWS_DEFAULT_REGION environment variable
562 * 3. The region property in the config file.
563 */
564 struct aws_credentials_provider_sts_options {
565 /*
566 * Connection bootstrap to use for any network connections made while sourcing credentials
567 */
568 struct aws_client_bootstrap *bootstrap;
569
570 /*
571 * Client TLS context to use when querying STS.
572 * Required.
573 */
574 struct aws_tls_ctx *tls_ctx;
575
576 /*
577 * Credentials provider to be used to sign the requests made to STS to fetch credentials.
578 */
579 struct aws_credentials_provider *creds_provider;
580
581 /*
582 * Arn of the role to assume by fetching credentials for
583 */
584 struct aws_byte_cursor role_arn;
585
586 /*
587 * Assumed role session identifier to be associated with the sourced credentials
588 */
589 struct aws_byte_cursor session_name;
590
591 /*
592 * (Optional) Unique identifier for assuming a role in another account
593 */
594 struct aws_byte_cursor external_id;
595
596 /*
597 * How long sourced credentials should remain valid for, in seconds. 900 is the minimum allowed value.
598 */
599 uint16_t duration_seconds;
600
601 /**
602 * (Optional) Http proxy configuration for the AssumeRole http request that fetches credentials
603 */
604 const struct aws_http_proxy_options *http_proxy_options;
605
606 /**
607 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
608 * aws_http_credentials_provider.h for more information.
609 */
610 const struct proxy_env_var_settings *proxy_ev_settings;
611
612 /**
613 * (Optional)
614 * Uses a cached config file profile collection (~/.aws/config). You can also pass a merged profile collection,
615 * which contains both a config file and a credentials file.
616 * If provided, config_file_name_override is ignored.
617 */
618 struct aws_profile_collection *profile_collection_cached;
619
620 /*
621 * (Optional)
622 * Override of what profile to use; if not set, 'default' will be used.
623 */
624 struct aws_byte_cursor profile_name_override;
625
626 /*
627 * (Optional)
628 * Override path to the profile config file (~/.aws/config by default).
629 */
630 struct aws_byte_cursor config_file_name_override;
631
632 struct aws_credentials_provider_shutdown_options shutdown_options;
633
634 /* For mocking, leave NULL otherwise */
635 struct aws_auth_http_system_vtable *function_table;
636 aws_io_clock_fn *system_clock_fn;
637 };
638
639 /**
640 *
641 * Configuration options for the process credentials provider
642 *
643 * The process credentials provider sources credentials from running a command or process.
644 * The command to run is sourced from a profile in the AWS config file, using the standard
645 * profile selection rules. The profile key the command is read from is "credential_process."
646 * E.g.:
647 * [default]
648 * credential_process=/opt/amazon/bin/my-credential-fetcher --argsA=abc
649 * On successfully running the command, the output should be a json data with the following
650 * format:
651 * {
652 "Version": 1,
653 "AccessKeyId": "accesskey",
654 "SecretAccessKey": "secretAccessKey"
655 "SessionToken": "....",
656 "Expiration": "2019-05-29T00:21:43Z"
657 }
658 * Version here identifies the command output format version.
659 */
660 struct aws_credentials_provider_process_options {
661 struct aws_credentials_provider_shutdown_options shutdown_options;
662 /**
663 * In which profile name to look for credential_process,
664 * if not provided, we will try environment variable: AWS_PROFILE.
665 */
666 struct aws_byte_cursor profile_to_use;
667
668 /**
669 * (Optional)
670 * Use a cached config profile collection. You can also pass a merged collection.
671 */
672 struct aws_profile_collection *config_profile_collection_cached;
673 };
674
675 /**
676 * Configuration options for the default credentials provider chain.
677 */
678 struct aws_credentials_provider_chain_default_options {
679 struct aws_credentials_provider_shutdown_options shutdown_options;
680
681 /*
682 * Connection bootstrap to use for any network connections made while sourcing credentials
683 */
684 struct aws_client_bootstrap *bootstrap;
685
686 /*
687 * Client TLS context to use for any secure network connections made while sourcing credentials.
688 *
689 * If not provided the default chain will construct a new one, but these
690 * are expensive objects so you are encouraged to pass in a shared one.
691 *
692 * Must be provided if using BYO_CRYPTO.
693 */
694 struct aws_tls_ctx *tls_ctx;
695
696 /**
697 * (Optional)
698 * Use a cached merged profile collection. A merge collection has both config file
699 * (~/.aws/config) and credentials file based profile collection (~/.aws/credentials) using
700 * `aws_profile_collection_new_from_merge`.
701 */
702 struct aws_profile_collection *profile_collection_cached;
703
704 /*
705 * (Optional)
706 * Override of what profile to use, if not set, 'default' will be used.
707 */
708 struct aws_byte_cursor profile_name_override;
709
710 /*
711 * (Optional)
712 * If enabled, the Environment Credentials Provider is not added to the chain.
713 */
714 bool skip_environment_credentials_provider;
715
716 /*
717 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
718 * aws_http_credentials_provider.h for more information.
719 */
720 const struct proxy_env_var_settings *proxy_ev_settings;
721 };
722
723 typedef int(aws_credentials_provider_delegate_get_credentials_fn)(
724 void *delegate_user_data,
725 aws_on_get_credentials_callback_fn callback,
726 void *callback_user_data);
727
728 /**
729 * Configuration options for the delegate credentials provider.
730 */
731 struct aws_credentials_provider_delegate_options {
732 struct aws_credentials_provider_shutdown_options shutdown_options;
733
734 /**
735 * Delegated get_credentials() callback.
736 */
737 aws_credentials_provider_delegate_get_credentials_fn *get_credentials;
738
739 /**
740 * User data for delegated callbacks.
741 */
742 void *delegate_user_data;
743 };
744
745 /**
746 * A (string) pair defining an identity provider and a valid login token sourced from it.
747 */
748 struct aws_cognito_identity_provider_token_pair {
749
750 /**
751 * Name of an identity provider
752 */
753 struct aws_byte_cursor identity_provider_name;
754
755 /**
756 * Valid login token source from the identity provider
757 */
758 struct aws_byte_cursor identity_provider_token;
759 };
760
761 typedef void(aws_credentials_provider_cognito_get_token_pairs_completion_fn)(
762 struct aws_cognito_identity_provider_token_pair *logins,
763 size_t login_count,
764 int error_code,
765 void *completion_user_data);
766
767 typedef int(aws_credentials_provider_cognito_get_token_pairs_async_fn)(
768 void *get_token_pairs_user_data,
769 aws_credentials_provider_cognito_get_token_pairs_completion_fn *completion_callback,
770 void *completion_user_data);
771
772 /**
773 * Configuration options needed to create a Cognito-based Credentials Provider
774 */
775 struct aws_credentials_provider_cognito_options {
776 struct aws_credentials_provider_shutdown_options shutdown_options;
777
778 /**
779 * Cognito service regional endpoint to source credentials from.
780 */
781 struct aws_byte_cursor endpoint;
782
783 /**
784 * Cognito identity to fetch credentials relative to.
785 */
786 struct aws_byte_cursor identity;
787
788 /**
789 * Optional set of identity provider token pairs to allow for authenticated identity access.
790 */
791 struct aws_cognito_identity_provider_token_pair *logins;
792 size_t login_count;
793
794 /**
795 * Optional ARN of the role to be assumed when multiple roles were received in the token from the identity provider.
796 */
797 struct aws_byte_cursor *custom_role_arn;
798
799 /**
800 * Connection bootstrap to use for network connections made while sourcing credentials
801 */
802 struct aws_client_bootstrap *bootstrap;
803
804 /**
805 * Client TLS context to use when querying cognito credentials.
806 * Required.
807 */
808 struct aws_tls_ctx *tls_ctx;
809
810 /**
811 * (Optional) Http proxy configuration for the http request that fetches credentials
812 */
813 const struct aws_http_proxy_options *http_proxy_options;
814
815 /**
816 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
817 * aws_http_credentials_provider.h for more information.
818 */
819 const struct proxy_env_var_settings *proxy_ev_settings;
820
821 /* For mocking the http layer in tests, leave NULL otherwise */
822 struct aws_auth_http_system_vtable *function_table;
823
824 /**
825 * Optional async function to allow for dynamic augmentation of the token pair set on a per-request basis.
826 */
827 aws_credentials_provider_cognito_get_token_pairs_async_fn *get_token_pairs;
828
829 /**
830 * User data that should be passed in to the get_token_pairs function as the first parameter. In practice, this
831 * will be a reference to a CRT binding object.
832 */
833 void *get_token_pairs_user_data;
834 };
835
836 /*
837 * Configuration options for the AWS login credentials provider.
838 */
839 struct aws_credentials_provider_login_options {
840 /*
841 * Optional shutdown callback and user data that is invoked during the shutdown of
842 * a credentials provider to destroy specific data that lives alongside the credenials
843 * provider.
844 */
845 struct aws_credentials_provider_shutdown_options shutdown_options;
846
847 /*
848 * Required
849 * Arn of the AWS login session.
850 */
851 struct aws_byte_cursor login_session;
852
853 /*
854 * Required
855 * Region the AWS login CreateOAuth2Token call
856 */
857 struct aws_byte_cursor login_region;
858
859 /*
860 * Optional.
861 * Directory where the login cache is located. Will use `.aws/login/cache` by default.
862 */
863 struct aws_byte_cursor login_cache_directory_override;
864
865 /*
866 * Override of what profile to use to source credentials from ('default' by default)
867 */
868 struct aws_byte_cursor profile_name_override;
869
870 /*
871 * Override path to the profile config file (~/.aws/config by default)
872 */
873 struct aws_byte_cursor config_file_name_override;
874
875 /*
876 * (Optional)
877 * Use a cached config profile collection. You can also pass a merged collection.
878 * config_file_name_override will be ignored if this option is provided.
879 */
880 struct aws_profile_collection *config_file_cached;
881
882 /*
883 * Connection bootstrap to use for any network connections made while sourcing credentials
884 * Required.
885 */
886 struct aws_client_bootstrap *bootstrap;
887
888 /*
889 * Client TLS context to use when querying the login provider.
890 * Required.
891 */
892 struct aws_tls_ctx *tls_ctx;
893
894 /*
895 * (Optional) Settings propagated down to http connection manager to choose proxy options from environment. Read
896 * aws_http_credentials_provider.h for more information.
897 */
898 const struct proxy_env_var_settings *proxy_ev_settings;
899
900 /* For mocking, leave NULL otherwise */
901 struct aws_auth_http_system_vtable *function_table;
902 aws_io_clock_fn *system_clock_fn;
903 };
904
905 /**
906 * Configuration options for `aws_credentials_new_with_options`
907 */
908 struct aws_credentials_options {
909
910 /* Value for the aws access key id field */
911 struct aws_byte_cursor access_key_id_cursor;
912 /* Value for the secret access key field */
913 struct aws_byte_cursor secret_access_key_cursor;
914 /* (Optional) security token associated with the credentials */
915 struct aws_byte_cursor session_token_cursor;
916 /* (Optional) account id associated with the credentials */
917 struct aws_byte_cursor account_id_cursor;
918 /* Time point, in seconds since epoch, that the credentials will no longer be valid.
919 * For credentials that do not expire, use UINT64_MAX. */
920 uint64_t expiration_timepoint_seconds;
921 };
922
923 AWS_EXTERN_C_BEGIN
924
925 /*
926 * Credentials APIs
927 *
928 * expiration_timepoint_seconds is the timepoint, in seconds since epoch, that the credentials will no longer
929 * be valid. For credentials that do not expire, use UINT64_MAX.
930 */
931
932 /**
933 * Creates a new set of aws credentials
934 *
935 * @param allocator memory allocator to use
936 * @param access_key_id_cursor value for the aws access key id field
937 * @param secret_access_key_cursor value for the secret access key field
938 * @param session_token_cursor (optional) security token associated with the credentials
939 * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
940 * be valid past. For credentials that do not expire, use UINT64_MAX
941 *
942 * @return a valid credentials object, or NULL
943 */
944 AWS_AUTH_API
945 struct aws_credentials *aws_credentials_new(
946 struct aws_allocator *allocator,
947 struct aws_byte_cursor access_key_id_cursor,
948 struct aws_byte_cursor secret_access_key_cursor,
949 struct aws_byte_cursor session_token_cursor,
950 uint64_t expiration_timepoint_seconds);
951
952 /**
953 * Creates a new set of aws credentials with account_id
954 *
955 * @param allocator memory allocator to use
956 * @param access_key_id_cursor value for the aws access key id field
957 * @param secret_access_key_cursor value for the secret access key field
958 * @param session_token_cursor (optional) security token associated with the credentials
959 * @param account_id (optional) value for the account_id field
960 * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
961 * be valid past. For credentials that do not expire, use UINT64_MAX
962 *
963 * @return a valid credentials object, or NULL
964 */
965 AWS_AUTH_API
966 struct aws_credentials *aws_credentials_new_with_options(
967 struct aws_allocator *allocator,
968 const struct aws_credentials_options *options);
969
970 /**
971 * Creates a new set of aws anonymous credentials.
972 * Use Anonymous credentials, when you want to skip the signing process.
973 *
974 * @param allocator memory allocator to use
975 *
976 * @return a valid credentials object, or NULL
977 */
978 AWS_AUTH_API
979 struct aws_credentials *aws_credentials_new_anonymous(struct aws_allocator *allocator);
980
981 /**
982 * Creates a new set of AWS credentials
983 *
984 * @param allocator memory allocator to use
985 * @param access_key_id value for the aws access key id field
986 * @param secret_access_key value for the secret access key field
987 * @param session_token (optional) security token associated with the credentials
988 * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
989 * be valid past. For credentials that do not expire, use UINT64_MAX
990 *
991 * @return a valid credentials object, or NULL
992 */
993 AWS_AUTH_API
994 struct aws_credentials *aws_credentials_new_from_string(
995 struct aws_allocator *allocator,
996 const struct aws_string *access_key_id,
997 const struct aws_string *secret_access_key,
998 const struct aws_string *session_token,
999 uint64_t expiration_timepoint_seconds);
1000
1001 /**
1002 * Creates a set of AWS credentials that includes an ECC key pair. These credentials do not have a value for
1003 * the secret access key; the ecc key takes over that field's role in sigv4a signing.
1004 *
1005 * @param allocator memory allocator to use for all memory allocations
1006 * @param access_key_id access key id for the credential set
1007 * @param ecc_key ecc key to use during signing when using these credentials
1008 * @param session_token (optional) session token associated with the credentials
1009 * @param expiration_timepoint_in_seconds (optional) if session-based, time at which these credentials expire
1010 * @return a new pair of AWS credentials, or NULL
1011 */
1012 AWS_AUTH_API
1013 struct aws_credentials *aws_credentials_new_ecc(
1014 struct aws_allocator *allocator,
1015 struct aws_byte_cursor access_key_id,
1016 struct aws_ecc_key_pair *ecc_key,
1017 struct aws_byte_cursor session_token,
1018 uint64_t expiration_timepoint_in_seconds);
1019
1020 /*
1021 * Takes a pair of AWS credentials and performs the sigv4a key expansion algorithm to generate a unique
1022 * ecc P256 key pair based on the credentials. The ecc key is written to the buffer in DER format.
1023 *
1024 * Sigv4a signing takes the raw DER-encoded ecc key as an optional parameter in signing (if not present,
1025 * key expansion will be done for the caller before signing).
1026 */
1027 AWS_AUTH_API
1028 struct aws_credentials *aws_credentials_new_ecc_from_aws_credentials(
1029 struct aws_allocator *allocator,
1030 const struct aws_credentials *credentials);
1031
1032 /**
1033 * Add a reference to some credentials
1034 *
1035 * @param credentials credentials to increment the ref count on
1036 */
1037 AWS_AUTH_API
1038 void aws_credentials_acquire(const struct aws_credentials *credentials);
1039
1040 /**
1041 * Remove a reference to some credentials
1042 *
1043 * @param credentials credentials to decrement the ref count on
1044 */
1045 AWS_AUTH_API
1046 void aws_credentials_release(const struct aws_credentials *credentials);
1047
1048 /**
1049 * Get the AWS access key id from a set of credentials
1050 *
1051 * @param credentials credentials to get the access key id from
1052 * @return a byte cursor to the access key id
1053 */
1054 AWS_AUTH_API
1055 struct aws_byte_cursor aws_credentials_get_access_key_id(const struct aws_credentials *credentials);
1056
1057 /**
1058 * Get the AWS secret access key from a set of credentials
1059 *
1060 * @param credentials credentials to get the secret access key from
1061 * @return a byte cursor to the secret access key
1062 */
1063 AWS_AUTH_API
1064 struct aws_byte_cursor aws_credentials_get_secret_access_key(const struct aws_credentials *credentials);
1065
1066 /**
1067 * Get the AWS session token from a set of credentials
1068 *
1069 * @param credentials credentials to get the session token from
1070 * @return a byte cursor to the session token or an empty byte cursor if there is no session token
1071 */
1072 AWS_AUTH_API
1073 struct aws_byte_cursor aws_credentials_get_session_token(const struct aws_credentials *credentials);
1074
1075 /**
1076 * Get the AWS account id from a set of credentials
1077 *
1078 * @param credentials to get the account id from
1079 * @return a byte cursor to the account id or an empty byte cursor if there is no account id
1080 */
1081 AWS_AUTH_API
1082 struct aws_byte_cursor aws_credentials_get_account_id(const struct aws_credentials *credentials);
1083
1084 /**
1085 * Get the expiration timepoint (in seconds since epoch) associated with a set of credentials
1086 *
1087 * @param credentials credentials to get the expiration timepoint for
1088 * @return the time, in seconds since epoch, the credentials will expire; UINT64_MAX for credentials
1089 * without a specific expiration time
1090 */
1091 AWS_AUTH_API
1092 uint64_t aws_credentials_get_expiration_timepoint_seconds(const struct aws_credentials *credentials);
1093
1094 /**
1095 * Get the elliptic curve key associated with this set of credentials
1096 * @param credentials credentials to get the the elliptic curve key for
1097 * @return the elliptic curve key associated with the credentials, or NULL if no key is associated with
1098 * these credentials
1099 */
1100 AWS_AUTH_API
1101 struct aws_ecc_key_pair *aws_credentials_get_ecc_key_pair(const struct aws_credentials *credentials);
1102
1103 /**
1104 * If credentials are anonymous, then the signing process is skipped.
1105 *
1106 * @param credentials credentials to check
1107 *
1108 * @return true if the credentials are anonymous; false otherwise.
1109 */
1110 AWS_AUTH_API
1111 bool aws_credentials_is_anonymous(const struct aws_credentials *credentials);
1112
1113 /**
1114 * Derives an ecc key pair (based on the nist P256 curve) from the access key id and secret access key components
1115 * of a set of AWS credentials using an internal key derivation specification. Used to perform sigv4a signing in
1116 * the hybrid mode based on AWS credentials.
1117 *
1118 * @param allocator memory allocator to use for all memory allocations
1119 * @param credentials AWS credentials to derive the ECC key from using the AWS sigv4a key derivation specification
1120 * @return a new ecc key pair or NULL on failure
1121 */
1122 AWS_AUTH_API
1123 struct aws_ecc_key_pair *aws_ecc_key_pair_new_ecdsa_p256_key_from_aws_credentials(
1124 struct aws_allocator *allocator,
1125 const struct aws_credentials *credentials);
1126
1127 /*
1128 * Credentials provider APIs
1129 */
1130
1131 /**
1132 * Release a reference to a credentials provider
1133 *
1134 * @param provider provider to decrement the ref count on
1135 */
1136 AWS_AUTH_API
1137 struct aws_credentials_provider *aws_credentials_provider_release(struct aws_credentials_provider *provider);
1138
1139 /*
1140 * Add a reference to a credentials provider
1141 *
1142 * @param provider provider to increment the ref count on
1143 */
1144 AWS_AUTH_API
1145 struct aws_credentials_provider *aws_credentials_provider_acquire(struct aws_credentials_provider *provider);
1146
1147 /*
1148 * Async function for retrieving credentials from a provider
1149 *
1150 * @param provider credentials provider to source from
1151 * @param callback completion callback to invoke when the fetch has completed or failed
1152 * @param user_data user data to pass to the completion callback
1153 *
1154 * @return AWS_OP_SUCCESS if the fetch was successfully started, AWS_OP_ERR otherwise. The completion
1155 * callback will only be invoked if-and-only-if the return value was AWS_OP_SUCCESS.
1156 *
1157 */
1158 AWS_AUTH_API
1159 int aws_credentials_provider_get_credentials(
1160 struct aws_credentials_provider *provider,
1161 aws_on_get_credentials_callback_fn callback,
1162 void *user_data);
1163
1164 /*
1165 * Credentials provider variant creation
1166 */
1167
1168 /**
1169 * Creates a simple provider that just returns a fixed set of credentials
1170 *
1171 * @param allocator memory allocator to use for all memory allocation
1172 * @param options provider-specific configuration options
1173 *
1174 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1175 */
1176 AWS_AUTH_API
1177 struct aws_credentials_provider *aws_credentials_provider_new_static(
1178 struct aws_allocator *allocator,
1179 const struct aws_credentials_provider_static_options *options);
1180
1181 /**
1182 * Creates a simple anonymous credentials provider
1183 *
1184 * @param allocator memory allocator to use for all memory allocation
1185 * @param shutdown_options an optional shutdown callback that gets
1186 * invoked when the resources used by the provider are no longer in use.
1187 *
1188 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1189 */
1190 AWS_AUTH_API
1191 struct aws_credentials_provider *aws_credentials_provider_new_anonymous(
1192 struct aws_allocator *allocator,
1193 const struct aws_credentials_provider_shutdown_options *shutdown_options);
1194
1195 /**
1196 * Creates a provider that returns credentials sourced from the environment variables:
1197 *
1198 * AWS_ACCESS_KEY_ID
1199 * AWS_SECRET_ACCESS_KEY
1200 * AWS_SESSION_TOKEN
1201 *
1202 * @param allocator memory allocator to use for all memory allocation
1203 * @param options provider-specific configuration options
1204 *
1205 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1206 */
1207 AWS_AUTH_API
1208 struct aws_credentials_provider *aws_credentials_provider_new_environment(
1209 struct aws_allocator *allocator,
1210 const struct aws_credentials_provider_environment_options *options);
1211
1212 /**
1213 * Creates a provider that functions as a caching decorating of another provider.
1214 *
1215 * For example, the default chain is implemented as:
1216 *
1217 * CachedProvider -> ProviderChain(EnvironmentProvider -> ProfileProvider -> ECS/EC2IMD etc...)
1218 *
1219 * A reference is taken on the target provider
1220 *
1221 * @param allocator memory allocator to use for all memory allocation
1222 * @param options provider-specific configuration options
1223 *
1224 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1225 */
1226 AWS_AUTH_API
1227 struct aws_credentials_provider *aws_credentials_provider_new_cached(
1228 struct aws_allocator *allocator,
1229 const struct aws_credentials_provider_cached_options *options);
1230
1231 /**
1232 * Creates a provider that sources credentials from key-value profiles loaded from the aws credentials
1233 * file ("~/.aws/credentials" by default) and the aws config file ("~/.aws/config" by
1234 * default)
1235 *
1236 * @param allocator memory allocator to use for all memory allocation
1237 * @param options provider-specific configuration options
1238 *
1239 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1240 */
1241 AWS_AUTH_API
1242 struct aws_credentials_provider *aws_credentials_provider_new_profile(
1243 struct aws_allocator *allocator,
1244 const struct aws_credentials_provider_profile_options *options);
1245
1246 /**
1247 * Creates a provider that assumes an IAM role via. STS AssumeRole() API. This provider will fetch new credentials
1248 * upon each call to aws_credentials_provider_get_credentials().
1249 *
1250 * @param allocator memory allocator to use for all memory allocation
1251 * @param options provider-specific configuration options
1252 *
1253 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1254 */
1255 AWS_AUTH_API
1256 struct aws_credentials_provider *aws_credentials_provider_new_sts(
1257 struct aws_allocator *allocator,
1258 const struct aws_credentials_provider_sts_options *options);
1259
1260 /**
1261 * Creates a provider that sources credentials from an ordered sequence of providers, with the overall result
1262 * being from the first provider to return a valid set of credentials
1263 *
1264 * References are taken on all supplied providers
1265 *
1266 * @param allocator memory allocator to use for all memory allocation
1267 * @param options provider-specific configuration options
1268 *
1269 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1270 */
1271 AWS_AUTH_API
1272 struct aws_credentials_provider *aws_credentials_provider_new_chain(
1273 struct aws_allocator *allocator,
1274 const struct aws_credentials_provider_chain_options *options);
1275
1276 /**
1277 * Creates a provider that sources credentials from the ec2 instance metadata service
1278 *
1279 * @param allocator memory allocator to use for all memory allocation
1280 * @param options provider-specific configuration options
1281 *
1282 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1283 */
1284 AWS_AUTH_API
1285 struct aws_credentials_provider *aws_credentials_provider_new_imds(
1286 struct aws_allocator *allocator,
1287 const struct aws_credentials_provider_imds_options *options);
1288
1289 /**
1290 * Creates a provider that sources credentials from the ecs role credentials service and reads the required params from
1291 * environment variables
1292 *
1293 * @param allocator memory allocator to use for all memory allocation
1294 * @param options provider-specific configuration options
1295 *
1296 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1297 */
1298 AWS_AUTH_API
1299 struct aws_credentials_provider *aws_credentials_provider_new_ecs_from_environment(
1300 struct aws_allocator *allocator,
1301 const struct aws_credentials_provider_ecs_environment_options *options);
1302
1303 /**
1304 * Creates a provider that sources credentials from the ecs role credentials service
1305 * This function doesn't read anything from the environment and requires everything to be explicitly passed in.
1306 * If you need to read properties from the environment, use the `aws_credentials_provider_new_ecs_from_environment`.
1307 *
1308 * @param allocator memory allocator to use for all memory allocation
1309 * @param options provider-specific configuration options
1310 *
1311 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1312 */
1313 AWS_AUTH_API
1314 struct aws_credentials_provider *aws_credentials_provider_new_ecs(
1315 struct aws_allocator *allocator,
1316 const struct aws_credentials_provider_ecs_options *options);
1317
1318 /**
1319 * Creates a provider that sources credentials from IoT Core
1320 *
1321 * @param allocator memory allocator to use for all memory allocation
1322 * @param options provider-specific configuration options
1323 *
1324 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1325 */
1326 AWS_AUTH_API
1327 struct aws_credentials_provider *aws_credentials_provider_new_x509(
1328 struct aws_allocator *allocator,
1329 const struct aws_credentials_provider_x509_options *options);
1330
1331 /**
1332 * Creates a provider that sources credentials from STS using AssumeRoleWithWebIdentity
1333 *
1334 * @param allocator memory allocator to use for all memory allocation
1335 * @param options provider-specific configuration options
1336 *
1337 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1338 */
1339 AWS_AUTH_API
1340 struct aws_credentials_provider *aws_credentials_provider_new_sts_web_identity(
1341 struct aws_allocator *allocator,
1342 const struct aws_credentials_provider_sts_web_identity_options *options);
1343
1344 /**
1345 * Creates a provider that sources credentials from SSO using a SSOToken.
1346 *
1347 * @param allocator memory allocator to use for all memory allocation
1348 * @param options provider-specific configuration options
1349 *
1350 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1351 */
1352 AWS_AUTH_API
1353 struct aws_credentials_provider *aws_credentials_provider_new_sso(
1354 struct aws_allocator *allocator,
1355 const struct aws_credentials_provider_sso_options *options);
1356
1357 /*
1358 * Creates a provider that sources credentials from running an external command or process
1359 *
1360 * @param allocator memory allocator to use for all memory allocation
1361 * @param options provider-specific configuration options
1362 *
1363 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1364 */
1365 AWS_AUTH_API
1366 struct aws_credentials_provider *aws_credentials_provider_new_process(
1367 struct aws_allocator *allocator,
1368 const struct aws_credentials_provider_process_options *options);
1369
1370 /**
1371 * Create a credentials provider depends on provided vtable to fetch the credentials.
1372 *
1373 * @param allocator memory allocator to use for all memory allocation
1374 * @param options provider-specific configuration options
1375 *
1376 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1377 */
1378 AWS_AUTH_API
1379 struct aws_credentials_provider *aws_credentials_provider_new_delegate(
1380 struct aws_allocator *allocator,
1381 const struct aws_credentials_provider_delegate_options *options);
1382
1383 /**
1384 * Creates a provider that sources credentials from the Cognito-Identity service via an
1385 * invocation of the GetCredentialsForIdentity API call.
1386 *
1387 * @param allocator memory allocator to use for all memory allocation
1388 * @param options provider-specific configuration options
1389 *
1390 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1391 */
1392 AWS_AUTH_API
1393 struct aws_credentials_provider *aws_credentials_provider_new_cognito(
1394 struct aws_allocator *allocator,
1395 const struct aws_credentials_provider_cognito_options *options);
1396
1397 /**
1398 * Creates a cognito-based provider that has a caching layer wrapped around it
1399 *
1400 * @param allocator memory allocator to use for all memory allocation
1401 * @param options cognito-specific configuration options
1402 *
1403 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1404 */
1405 AWS_AUTH_API
1406 struct aws_credentials_provider *aws_credentials_provider_new_cognito_caching(
1407 struct aws_allocator *allocator,
1408 const struct aws_credentials_provider_cognito_options *options);
1409
1410 /**
1411 * Creates a provider that sources credentials from AWS Login.
1412 *
1413 * @param allocator memory allocator to use for all memory allocation
1414 * @param options provider-specific configuration options
1415 *
1416 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1417 */
1418 AWS_AUTH_API
1419 struct aws_credentials_provider *aws_credentials_provider_new_login(
1420 struct aws_allocator *allocator,
1421 const struct aws_credentials_provider_login_options *options);
1422
1423 /**
1424 * Creates the default provider chain used by most AWS SDKs.
1425 *
1426 * Generally:
1427 *
1428 * (1) Environment
1429 * (2) Profile
1430 * - STSCredentialsProvider
1431 * - ProcessCredentialsProvider
1432 * - ProfileCredentialsProvider
1433 * (3) STS web identity
1434 * (4) (conditional, off by default) ECS
1435 * (5) (conditional, on by default) EC2 Instance Metadata
1436 *
1437 * Support for environmental control of the default provider chain is not yet
1438 * implemented.
1439 *
1440 * @param allocator memory allocator to use for all memory allocation
1441 * @param options provider-specific configuration options
1442 *
1443 * @return the newly-constructed credentials provider, or NULL if an error occurred.
1444 */
1445 AWS_AUTH_API
1446 struct aws_credentials_provider *aws_credentials_provider_new_chain_default(
1447 struct aws_allocator *allocator,
1448 const struct aws_credentials_provider_chain_default_options *options);
1449
1450 AWS_AUTH_API extern const struct aws_auth_http_system_vtable *g_aws_credentials_provider_http_function_table;
1451
1452 AWS_EXTERN_C_END
1453 AWS_POP_SANE_WARNING_LEVEL
1454
1455 #endif /* AWS_AUTH_CREDENTIALS_H */