-
Notifications
You must be signed in to change notification settings - Fork 55
Add STS assume role and web identity credential providers #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I didn't setup the cross-repo branches for this so the |
| */ | ||
| public class StsAssumeRoleCredentialsProvider public constructor( | ||
| credentialsProvider: CredentialsProvider, | ||
| roleArn: String? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correctness
Aren't some of these required? If so I think we should make them required arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch.
| } | ||
|
|
||
| // Adapt SDK credential provider to CRT version | ||
| internal fun adapt(credentialsProvider: CredentialsProvider): CredentialsProviderCrt = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh the amount of layers here is painful and admittedly hard to follow at times (nothing you did wrong of course)
| // Adapt SDK credential provider to CRT version | ||
| internal fun CredentialsProvider.toCrtCredentialsProvider(): CredentialsProviderCrt = | ||
| object : CredentialsProviderCrt { | ||
| override fun close() { } | ||
|
|
||
| override suspend fun getCredentials(): Credentials { | ||
| val credentials = this@toCrtCredentialsProvider.getCredentials() | ||
| return Credentials(credentials.accessKeyId, credentials.secretAccessKey, credentials.sessionToken) | ||
| } | ||
|
|
||
| override suspend fun waitForShutdown() { } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness: Doesn't this already exist as CredentialsProviderCrtProxy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It surely does, nice catch
| override val crtProvider: StsAssumeRoleCredentialsProviderCrt = StsAssumeRoleCredentialsProviderCrt.build { | ||
| clientBootstrap = SdkDefaultIO.ClientBootstrap | ||
| tlsContext = SdkDefaultIO.TlsContext | ||
| this.credentialsProvider = CredentialsProviderCrtProxy(credentialsProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Now that I'm looking at the usage of the CRT proxy a little closer I believe there may be room for improvement. We've got CrtCredentialsProvider for wrapping CRT in SDK and we've got CredentialsProviderCrtProxy for wrapping SDK in CRT. But if someone passes in a CrtCredentialsProvider to this STS impl, we don't need to re-wrap it as CRT...we can just unwrap it from SDK right?
I think we may need a new helper method in CrtCredentialUtils.kt:
internal fun asCrt(sdkProvider: CredentialsProvider): CredentialsProviderCrt = when (sdkProvider) {
is CrtCredentialsProvider -> sdkProvider.crtProvider
else -> CredentialsProviderCrtProxy(sdkProvider)
}
Issue #
#325
#19
Description of changes
aws-crt-kotlincredential providers: sts assume role and sts web identityScope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.