| 1 | #ifndef AWS_AUTH_TOKEN_PROVIDERS_PRIVATE_H |
| 2 | #define AWS_AUTH_TOKEN_PROVIDERS_PRIVATE_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/auth/credentials.h> |
| 11 | |
| 12 | /** |
| 13 | * Configuration options for a provider that sources sso token information from the aws profile (by default |
| 14 | * ~/.aws/config) and token from ~/.aws/sso/cache/<sha1 of start url>.json. |
| 15 | */ |
| 16 | struct aws_token_provider_sso_profile_options { |
| 17 | struct aws_credentials_provider_shutdown_options shutdown_options; |
| 18 | |
| 19 | /* |
| 20 | * Override of what profile to use to source credentials from ('default' by default) |
| 21 | */ |
| 22 | struct aws_byte_cursor profile_name_override; |
| 23 | |
| 24 | /* |
| 25 | * Override path to the profile config file (~/.aws/config by default) |
| 26 | */ |
| 27 | struct aws_byte_cursor config_file_name_override; |
| 28 | |
| 29 | /** |
| 30 | * (Optional) |
| 31 | * Use a cached config profile collection. You can also pass a merged collection. |
| 32 | * config_file_name_override will be ignored if this option is provided. |
| 33 | */ |
| 34 | struct aws_profile_collection *config_file_cached; |
| 35 | |
| 36 | /* For mocking, leave NULL otherwise */ |
| 37 | aws_io_clock_fn *system_clock_fn; |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * Configuration options for a provider that sources sso token information from the aws profile (by default |
| 42 | * ~/.aws/config) and token from ~/.aws/sso/cache/<sha1 of session name>.json. |
| 43 | */ |
| 44 | struct aws_token_provider_sso_session_options { |
| 45 | struct aws_credentials_provider_shutdown_options shutdown_options; |
| 46 | |
| 47 | /* |
| 48 | * Override of what profile to use to source credentials from ('default' by default) |
| 49 | */ |
| 50 | struct aws_byte_cursor profile_name_override; |
| 51 | |
| 52 | /* |
| 53 | * Override path to the profile config file (~/.aws/config by default) |
| 54 | */ |
| 55 | struct aws_byte_cursor config_file_name_override; |
| 56 | |
| 57 | /** |
| 58 | * (Optional) |
| 59 | * Use a cached config profile collection. You can also pass a merged collection. |
| 60 | * config_file_name_override will be ignored if this option is provided. |
| 61 | */ |
| 62 | struct aws_profile_collection *config_file_cached; |
| 63 | |
| 64 | /* |
| 65 | * Connection bootstrap to use for any network connections made |
| 66 | */ |
| 67 | struct aws_client_bootstrap *bootstrap; |
| 68 | |
| 69 | /* |
| 70 | * Client TLS context to use for any network connections made. |
| 71 | */ |
| 72 | struct aws_tls_ctx *tls_ctx; |
| 73 | |
| 74 | /* For mocking, leave NULL otherwise */ |
| 75 | aws_io_clock_fn *system_clock_fn; |
| 76 | }; |
| 77 | |
| 78 | AWS_EXTERN_C_BEGIN |
| 79 | |
| 80 | /** |
| 81 | * Creates a provider that sources sso token based credentials from key-value profiles loaded from the aws |
| 82 | * config("~/.aws/config" by default) and ~/.aws/sso/cache/<sha1 of start url>.json |
| 83 | * This is the legacy way which doesn't support refreshing credentials. |
| 84 | * |
| 85 | * @param allocator memory allocator to use for all memory allocation |
| 86 | * @param options provider-specific configuration options |
| 87 | * |
| 88 | * @return the newly-constructed credentials provider, or NULL if an error occurred. |
| 89 | */ |
| 90 | AWS_AUTH_API |
| 91 | struct aws_credentials_provider *aws_token_provider_new_sso_profile( |
| 92 | struct aws_allocator *allocator, |
| 93 | const struct aws_token_provider_sso_profile_options *options); |
| 94 | |
| 95 | /** |
| 96 | * Creates a provider that sources sso token based credentials from key-value profiles loaded from the aws |
| 97 | * config("~/.aws/config" by default) and ~/.aws/sso/cache/<sha1 of session name>.json |
| 98 | * Note: Token refresh is not currently supported |
| 99 | * |
| 100 | * @param allocator memory allocator to use for all memory allocation |
| 101 | * @param options provider-specific configuration options |
| 102 | * |
| 103 | * @return the newly-constructed credentials provider, or NULL if an error occurred. |
| 104 | */ |
| 105 | AWS_AUTH_API |
| 106 | struct aws_credentials_provider *aws_token_provider_new_sso_session( |
| 107 | struct aws_allocator *allocator, |
| 108 | const struct aws_token_provider_sso_session_options *options); |
| 109 | |
| 110 | AWS_EXTERN_C_END |
| 111 | |
| 112 | #endif /* AWS_AUTH_TOKEN_PROVIDERS_PRIVATE_H */ |