Skip to content

Service sdk sigv4 #1381

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

Merged
merged 12 commits into from
Aug 19, 2025
Merged

Service sdk sigv4 #1381

merged 12 commits into from
Aug 19, 2025

Conversation

luigi617
Copy link
Collaborator

@luigi617 luigi617 commented Aug 14, 2025

  • SigV4 and SigV4A implementation (look at AWSAuthentication.kt, SigV4.kt, SigV4A.kt)
  • Unit tests
  • separation of files for easier readability

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.

@luigi617 luigi617 requested a review from a team as a code owner August 14, 2025 03:42

This comment has been minimized.

@luigi617 luigi617 added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Aug 14, 2025

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

private lateinit var proc: Process

@BeforeAll
fun boot() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible the boot and shutdown function should be shared between authentication and cbor tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They shouldn't share these functions because the Smithy models used are different, meaning they rely on different services. However, this is something I’ve thought about before. Different tests could share the boot and shutdown functions if we created a large Smithy model that included everything. This would make the tests faster since fewer services would need to be started. On the other hand, it would make the code harder to read, maintain, and extend.

Comment on lines 108 to 109
val accessKey = "AKIAIOSFODNN7EXAMPLE"
val secretKey = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you extract the accessKey and secretKey prefixes and make them constants? For readability, or if it doesn't break the tests, could you remove the prefix all together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't understand this comment, I know the prefix of access key for sigv4 is AKIA, but what is the prefix of secret key? and what do you mean by removing the prefix all together?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the wJalrXUtnFEMI/K7MDENG+bPxRfiCY that is repeated for a lot of the secret keys and AKIAIOSFODNN7 in the access keys. Is it necessary for the SIGV4 signing to work? It's not a big deal if you leave it as is but I noticed it made the tests harder to follow. I meant just using EXAMPLEKEY, WRONGKEY, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I change the access key and secret key to make it easier

withBlock("sigV4(name = #S) {", "}", "aws-sigv4") {
write("region = #T.region", ServiceTypes(pkgName).serviceFrameworkConfig)
val serviceSigV4AuthTrait = serviceShape.getTrait<SigV4Trait>()
if (serviceSigV4AuthTrait != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be rendering the

withBlock("sigV4(name = #S) {", "}", "aws-sigv4") {

block from above if the service doesn't have the SigV4 trait?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think yes, because once generated, you should allow user to use sigv4 if they want to add it manually

writer.withBlock("internal object SigV4CredentialStore {", "}") {
write("private val table: Map<String, #T> = mapOf()", RuntimeTypes.Auth.Credentials.AwsCredentials.Credentials)
withBlock("internal fun get(accessKeyId: String): #T? {", "}", RuntimeTypes.Auth.Credentials.AwsCredentials.Credentials) {
write("// TODO: implement me: return Credentials(accessKeyId = ..., secretAccessKey = ...)")
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this comment, wouldn't the implementer just need to populate the table val ? Also can you add a similar comment for SigV4a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to let user have the flexibility to choose between populating the table or using other methods to get the Credentials (maybe calling another api or accessing database)

This comment has been minimized.

Comment on lines 108 to 109
val accessKey = "AKIAIOSFODNN7EXAMPLE"
val secretKey = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the wJalrXUtnFEMI/K7MDENG+bPxRfiCY that is repeated for a lot of the secret keys and AKIAIOSFODNN7 in the access keys. Is it necessary for the SIGV4 signing to work? It's not a big deal if you leave it as is but I noticed it made the tests harder to follow. I meant just using EXAMPLEKEY, WRONGKEY, etc.

Copy link

Affected Artifacts

Changed in size
Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
telemetry-provider-micrometer-jvm.jar 22,796 22,788 8 0.04%
runtime-core-jvm.jar 834,702 834,754 -52 -0.01%
http-auth-jvm.jar 18,009 18,974 -965 -5.09%
http-client-jvm.jar 324,679 347,830 -23,151 -6.66%

@luigi617 luigi617 merged commit 48e75cb into server-sdk-main Aug 19, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants