Skip to content

Commit d603ba0

Browse files
sbisciglTingDaoK
andauthored
bind out log-in provider (#798)
Co-authored-by: Dengke Tang <dengket@amazon.com>
1 parent aa37a25 commit d603ba0

File tree

9 files changed

+80
-7
lines changed

9 files changed

+80
-7
lines changed

crt/aws-lc

crt/s2n

Submodule s2n updated from 30f40f2 to 6aefe74

include/aws/crt/auth/Credentials.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,44 @@ namespace Aws
494494
Io::TlsConnectionOptions TlsConnectionOptions;
495495
};
496496

497+
/**
498+
* Configuration options for the STS Web Identity credentials provider
499+
*/
500+
struct AWS_CRT_CPP_API CredentialsProviderLoginConfig
501+
{
502+
CredentialsProviderLoginConfig();
503+
504+
/**
505+
* The arn associated with the AWS login session.
506+
*/
507+
String LoginSession;
508+
509+
/**
510+
* Overrides the login cache directory. by default the cache directory
511+
* is located at `~/.aws/login/cache`.
512+
*/
513+
String LoginCacheOverride;
514+
515+
/**
516+
* The region associated with the AWS Login call
517+
*/
518+
String LoginRegion;
519+
520+
/**
521+
* Connection bootstrap to use to create the http connection required to
522+
* query credentials from the STS provider
523+
*
524+
* Note: If null, then the default ClientBootstrap is used
525+
* (see Aws::Crt::ApiHandle::GetOrCreateStaticDefaultClientBootstrap)
526+
*/
527+
Io::ClientBootstrap *Bootstrap;
528+
529+
/**
530+
* TLS configuration for secure socket connections.
531+
*/
532+
Io::TlsConnectionOptions TlsConnectionOptions;
533+
};
534+
497535
/**
498536
* Simple credentials provider implementation that wraps one of the internal C-based implementations.
499537
*
@@ -625,6 +663,13 @@ namespace Aws
625663
const CredentialsProviderSTSWebIdentityConfig &config,
626664
Allocator *allocator = ApiAllocator());
627665

666+
/**
667+
* Creates a AWS Login based credentials provider
668+
*/
669+
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderLogin(
670+
const CredentialsProviderLoginConfig &config,
671+
Allocator *allocator = ApiAllocator());
672+
628673
private:
629674
static void s_onCredentialsResolved(aws_credentials *credentials, int error_code, void *user_data);
630675

source/auth/Credentials.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,34 @@ namespace Aws
514514
return s_CreateWrappedProvider(
515515
aws_credentials_provider_new_sts_web_identity(allocator, &raw_config), allocator);
516516
}
517+
518+
CredentialsProviderLoginConfig::CredentialsProviderLoginConfig() : Bootstrap(nullptr) {}
519+
520+
std::shared_ptr<ICredentialsProvider> CredentialsProvider::CreateCredentialsProviderLogin(
521+
const CredentialsProviderLoginConfig &config,
522+
Allocator *allocator)
523+
{
524+
struct aws_credentials_provider_login_options raw_config;
525+
AWS_ZERO_STRUCT(raw_config);
526+
527+
raw_config.login_session = aws_byte_cursor_from_c_str(config.LoginSession.c_str());
528+
raw_config.login_cache_directory_override =
529+
aws_byte_cursor_from_c_str(config.LoginCacheOverride.c_str());
530+
raw_config.login_region = aws_byte_cursor_from_c_str(config.LoginRegion.c_str());
531+
532+
raw_config.bootstrap =
533+
(config.Bootstrap != nullptr)
534+
? config.Bootstrap->GetUnderlyingHandle()
535+
: ApiHandle::GetOrCreateStaticDefaultClientBootstrap()->GetUnderlyingHandle();
536+
537+
const auto connectionOptions = config.TlsConnectionOptions.GetUnderlyingHandle();
538+
if (connectionOptions != nullptr)
539+
{
540+
raw_config.tls_ctx = connectionOptions->ctx;
541+
}
542+
543+
return s_CreateWrappedProvider(aws_credentials_provider_new_login(allocator, &raw_config), allocator);
544+
}
517545
} // namespace Auth
518546
} // namespace Crt
519547
} // namespace Aws

0 commit comments

Comments
 (0)