Debian Codegraph @

crt/aws-c-auth/include/aws/auth/private/aws_http_credentials_provider.h

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5 #ifndef AWS_HTTP_CREDENTIALS_PROVIDER_H
6 #define AWS_HTTP_CREDENTIALS_PROVIDER_H
7
8 #include <aws/auth/credentials.h>
9 #include <aws/http/connection_manager.h>
10 #include <aws/http/request_response.h>
11
12 AWS_PUSH_SANE_WARNING_LEVEL
13
14 /**
15 * Configuration needed to create a underlying http client.
16 */
17 struct aws_credentials_provider_http_options {
18 struct aws_credentials_provider_shutdown_options shutdown_options;
19 /*
20 * Required.
21 * Connection bootstrap to use for any network connections
22 * made while sourcing credentials.
23 */
24 struct aws_client_bootstrap *bootstrap;
25
26 /*
27 * Required.
28 * Client TLS context to use when querying a http based provider.
29 */
30 struct aws_tls_ctx *tls_ctx;
31
32 /*
33 * Required
34 * Maximum number of connections the underlying manager is
35 * allowed to contain.
36 */
37 size_t max_connections;
38
39 /*
40 * Optional.
41 * Endpoint override for service endpoint. Leave null
42 * to use default endpoint.
43 */
44 struct aws_byte_cursor endpoint;
45
46 /*
47 * Optional
48 * Retry strategy override. Leave null
49 * to use default retry strategy.
50 */
51 struct aws_retry_strategy *retry_strategy;
52
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
62 /* For mocking the http layer in tests, leave NULL otherwise */
63 const struct aws_auth_http_system_vtable *function_table;
64 };
65
66 /**
67 * aws_htttp_query_context - context for each outstanding http query.
68 */
69 struct aws_http_query_context {
70 /* immutable post-creation */
71 struct aws_allocator *allocator;
72 struct aws_credentials_provider *provider;
73 aws_on_get_credentials_callback_fn *original_callback;
74 void *original_user_data;
75
76 /* mutable */
77 struct aws_http_connection *connection;
78 struct aws_http_message *request;
79 struct aws_byte_buf payload;
80 struct aws_retry_token *retry_token;
81 struct aws_byte_buf path_and_query;
82
83 int status_code;
84 int error_code;
85
86 // implementation-specific data and errors
87 void *parameters;
88 void *request_data;
89 };
90
91 typedef int(create_request_fn)(struct aws_http_query_context *query_context, void *user_data);
92 typedef void(finalize_credentials_fn)(struct aws_http_query_context *query_context);
93 typedef void(clean_up_parameters_fn)(void *parameters);
94 typedef void(create_request_data_fn)(struct aws_http_query_context *query_context);
95 typedef void(reset_request_data_fn)(struct aws_http_query_context *query_context);
96
97 /**
98 * Implementation specific userdata for the http provider.
99 */
100 struct aws_http_credentials_provider_user_data {
101 /*
102 * owning pointer to implementation specific data. i.e. values that
103 * could be used during request creation.
104 */
105 void *parameters;
106
107 /*
108 * implementation specific callbacks for creating and cleaning up
109 * the underlying http request,
110 */
111 struct aws_http_credentials_provider_request_vtable *request_vtable;
112 };
113
114 /**
115 * A table to hold implementation specific values for
116 * an http credentials provider.
117 */
118 struct aws_http_credentials_provider_request_vtable {
119 /*
120 * Creates the request to be sent via the underlying http client.
121 */
122 create_request_fn *create_request_fn;
123
124 /*
125 * Creates credentials options. This is used to create the
126 * credentials that are returned to the user
127 */
128 finalize_credentials_fn *finalize_credentials_fn;
129
130 /*
131 * cleans up the parameters that are provided to the implemetatnion.
132 */
133 clean_up_parameters_fn *clean_up_parameters_fn;
134
135 /*
136 * implementation specific data that is created each request.
137 */
138 create_request_data_fn *create_request_data_fn;
139
140 /*
141 * implementation specific data that is destroyed each request.
142 */
143 reset_request_data_fn *reset_request_data_fn;
144 };
145
146 AWS_EXTERN_C_BEGIN
147
148 /**
149 * Initializes a underlying http based credentials provider.
150 *
151 * @param allocator memory allocator to use
152 * @param provider allocated instance of provider that will be initialized with
153 * a http based credentials fetching implementation.
154 * @param options standard http options.
155 * @param user_data implementation specific branching for http based providers
156 * such as hot to create requests.
157 * @return error code if encountered.
158 */
159 AWS_AUTH_API
160 int aws_http_credentials_provider_init_base(
161 struct aws_allocator *allocator,
162 struct aws_credentials_provider *provider,
163 struct aws_credentials_provider_http_options *options,
164 struct aws_http_credentials_provider_user_data *user_data);
165
166 AWS_EXTERN_C_END
167 AWS_POP_SANE_WARNING_LEVEL
168
169 #endif /* AWS_HTTP_CREDENTIALS_PROVIDER_H */