This library provides functionality to generate authentication tokens for Aurora DSQL databases. It uses AWS Signature Version 4 to create signed URLs that can be used as passwords when connecting to Aurora DSQL databases.
- Generate regular and admin authentication tokens for Aurora DSQL
- Support for custom AWS credentials
- Configurable token expiration time
- Region-specific token generation
- CMake 3.10 or higher
- C compiler with C99 support
- Git (for cloning submodules)
-
Clone the repository with submodules:
git clone --recursive https://github.com/marcbowes/aws-dsql-auth.git cd aws-dsql-auth
-
If you didn't clone with
--recursive
, initialize the submodules:git submodule update --init --recursive
-
Build the library:
./build.sh
#include <aws/dsql-auth/auth_token.h>
int main() {
struct aws_allocator *allocator = aws_default_allocator();
// Initialize AWS libraries
aws_common_library_init(allocator);
aws_auth_library_init(allocator);
// Set up the configuration
struct aws_dsql_auth_config config;
aws_dsql_auth_config_init(&config);
// Set configuration values (hostname and region are required)
aws_dsql_auth_config_set_hostname(&config, "mydb.dsql.us-east-1.on.aws");
// Option 1: Set region directly
struct aws_string *region_str = aws_string_new_from_c_str(allocator, "us-east-1");
aws_dsql_auth_config_set_region(&config, region_str);
// Option 2: Or infer region from hostname
// struct aws_string *region_str = NULL;
// aws_dsql_auth_config_infer_region(allocator, &config, ®ion_str);
// Optional: Set token expiration time (default is 900 seconds/15 minutes)
aws_dsql_auth_config_set_expires_in(&config, 900);
// Generate the token
struct aws_dsql_auth_token token = {0};
if (aws_dsql_auth_token_generate(&config, false, allocator, &token) == AWS_OP_SUCCESS) {
printf("Generated token: %s\n", aws_dsql_auth_token_get_str(&token));
aws_dsql_auth_token_clean_up(&token);
}
// Clean up
if (region_str) {
aws_string_destroy(region_str);
}
aws_dsql_auth_config_clean_up(&config);
aws_auth_library_clean_up();
return 0;
}
This library is licensed under the Apache License, Version 2.0.