Debian Codegraph @

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

raw symbols SCIP
1 #ifndef AWS_AUTH_TOKEN_PRIVATE_H
2 #define AWS_AUTH_TOKEN_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/common/date_time.h>
11
12 /* structure to represent a parsed sso token */
13 struct aws_sso_token {
14 struct aws_allocator *allocator;
15
16 struct aws_string *access_token;
17 struct aws_date_time expiration;
18 };
19
20 AWS_EXTERN_C_BEGIN
21
22 /* Construct token path which is ~/.aws/sso/cache/<hex encoded sha1 of input>.json */
23 AWS_AUTH_API
24 struct aws_string *aws_construct_sso_token_path(struct aws_allocator *allocator, const struct aws_string *input);
25
26 AWS_AUTH_API
27 void aws_sso_token_destroy(struct aws_sso_token *token);
28
29 /* Parse `aws_sso_token` from the give file path */
30 AWS_AUTH_API
31 struct aws_sso_token *aws_sso_token_new_from_file(struct aws_allocator *allocator, const struct aws_string *file_path);
32
33 /**
34 * Creates a set of AWS credentials based on a token with expiration.
35 *
36 * @param allocator memory allocator to use for all memory allocation
37 * @param token token for the credentials
38 * @param expiration_timepoint_in_seconds time at which these credentials expire
39 * @return a new pair of AWS credentials, or NULL
40 */
41 AWS_AUTH_API
42 struct aws_credentials *aws_credentials_new_token(
43 struct aws_allocator *allocator,
44 struct aws_byte_cursor token,
45 uint64_t expiration_timepoint_in_seconds);
46
47 /**
48 * Get the token from a set of AWS credentials
49 *
50 * @param credentials credentials to get the token from
51 * @return a byte cursor to the token or an empty byte cursor if there is no token
52 */
53 AWS_AUTH_API
54 struct aws_byte_cursor aws_credentials_get_token(const struct aws_credentials *credentials);
55
56 AWS_EXTERN_C_END
57
58 #endif /* AWS_AUTH_TOKEN_PRIVATE_H */