Skip to content

Conversation

lauzadis
Copy link
Contributor

@lauzadis lauzadis commented Jan 9, 2025

Issue #

Description of changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lauzadis lauzadis requested a review from a team as a code owner January 9, 2025 16:42
@lauzadis lauzadis added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Jan 9, 2025
@lauzadis lauzadis changed the title feat: add AuthTokenGenerator feat: add AuthTokenGenerator Jan 9, 2025

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

val config = AwsSigningConfig {
credentials = creds
this.region = region
service = serv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You can do this.service = service to avoid creating serv. Same for credentials: this.credentials = credentials.value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's not possible, I tried already. It's because those service and credentials are class parameters not function parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it some more and was able to get this to work: service = this@AuthTokenGenerator.service

Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing unit tests

Comment on lines 42 to 45
if (!::credentials.isInitialized || (credentials.expiresAt - clock.now()).absoluteValue <= credentialsRefreshBuffer) {
val resolved = credentialsProvider.resolve()
credentials = ExpiringValue(resolved, resolved.expiration ?: (clock.now() + DEFAULT_CREDENTIALS_EXPIRATION))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why duplicate this logic from our caching layer? Why not simply call the resolve method on the provider like we do in regular signing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we try to cache credentials instead of resolving them for every call to generateAuthToken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the default chain will cache credentials, but not if a user passes in a custom credentials provider.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, people who use a custom creds provider without caching will face the same behaviors in regular requests and in auth token generation, not all of which are necessarily negative. If someone intentionally wants fresh credentials every time or they have their own caching mechanism, we'll bypass that by adding in a new caching layer. We've got a clean, easy way for users to wrap their custom provider chains/impls in our caching provider which should be good enough.

This comment has been minimized.

This comment has been minimized.

@lauzadis lauzadis requested a review from ianbotsf January 10, 2025 15:15
Copy link

Affected Artifacts

Significantly increased in size

Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
aws-signing-common-jvm.jar 71,313 66,491 4,822 7.25%

@lauzadis lauzadis merged commit 5f5ec8f into main Jan 10, 2025
16 checks passed
@lauzadis lauzadis deleted the feat-auth-token-generator branch January 10, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acknowledge-artifact-size-increase no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants