Skip to content
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

fix: application of sigv4a #1186

Merged
merged 16 commits into from
Jan 24, 2024
Merged

fix: application of sigv4a #1186

merged 16 commits into from
Jan 24, 2024

Conversation

lauzadis
Copy link
Member

Addresses an issue with applying the SigV4A trait to services which don't model it

Issue #

#1184

Description of changes

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

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

@lauzadis lauzadis marked this pull request as ready for review January 22, 2024 17:16
@lauzadis lauzadis requested a review from a team as a code owner January 22, 2024 17:16
Copy link
Collaborator

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

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

We should probably try and get some integration/e2e tests around sigv4a and sigv4 for these services.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link
Contributor

@0marperez 0marperez left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -24,28 +24,34 @@ class SigV4AsymmetricTraitCustomization : KotlinIntegration {
// Needs to happen before the `SigV4AsymmetricAuthSchemeIntegration` & `SigV4AuthSchemeIntegration` (-50 & -50)
override val order: Byte = -60

// services which support SigV4A but don't model it
private val unmodeledSigV4aServices = listOf("s3", "eventbridge", "cloudfront keyvaluestore")
Copy link
Collaborator

Choose a reason for hiding this comment

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

correctness: I don't think cloudfront KVS needs to be in this integration anymore does it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is needed, this integration also applies the SigV4A trait. Do you want the new integration to replicate that and then remove cloudfront KVS from this integration?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I'm following, the new CFKVS integration is applying the sigv4a trait as well so it's redundant here no?

Copy link
Member Author

Choose a reason for hiding this comment

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

It wasn't when you first reviewed it, I just added that application and removed cloudfront keyvaluestore from the SigV4AsymmetricTraitCustomization

} else {
AuthTrait(it.valueSet + mutableSetOf(SigV4ATrait.ID))
}
} ?: AuthTrait(mutableSetOf(SigV4Trait.ID, SigV4ATrait.ID))
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: Probably want a remark in here about why this is ordered this way.

(It's because existing services (cloudfront KVS excluded) that use sigv4a do so through endpoint rules and it's not on the model. We don't know which operations it should apply for in those cases and so the safest thing to do is add it at the end and let endpoint rules change the priority as needed. Adding it this way registers support for the trait to let the rest of codegen Just Work (TM)).

*/
class CloudFrontKeyValueStoreSigV4APrioritizationCustomization : KotlinIntegration {
// Runs after SigV4AsymmetricTraitCustomization (-60) and before `SigV4AsymmetricAuthSchemeIntegration`(-50) and `SigV4AuthSchemeIntegration` (-50)
override val order: Byte = -55
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you'll even need to order this if you remove it from the other integration

* Modify the [AuthTrait] of the CloudFront KeyValueStore service, placing SigV4A before SigV4 in the
* prioritized list.
*/
class CloudFrontKeyValueStoreSigV4APrioritizationCustomization : KotlinIntegration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix: Other service specific customization's are in their own package directory.

suggestion/nit: This is more of a backfill, I'd consider renaming to BackfillSigv4A or something to that affect.

builder.removeTrait(AuthTrait.ID) // remove existing auth trait

// add a new auth trait with SigV4A in front
val authTrait = AuthTrait(mutableSetOf(SigV4ATrait.ID, SigV4Trait.ID))
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix: We should retain the existing auth trait in case it has other auth schemes over time (unlikely but no need to bake it in this way). I'd also only add sigv4a if the existing service model doesn't have it on the service shape.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

A new generated diff is ready to view.

@lauzadis lauzadis merged commit c6e6e0d into main Jan 24, 2024
15 checks passed
@lauzadis lauzadis deleted the fix-sigv4a branch January 24, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants