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: add UnsupportedSigningAlgorithmInterceptor to all sigV4a services #1245

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import software.amazon.smithy.model.transform.ModelTransformer
* NOTE: Won't add sigV4 trait (services that support sigV4A MUST support sigV4)
*/
class SigV4AsymmetricTraitCustomization : KotlinIntegration {
// Needs to happen before the `SigV4AsymmetricAuthSchemeIntegration` & `SigV4AuthSchemeIntegration` (-50 & -50)
// Needs to happen before the SigV4AsymmetricAuthSchemeIntegration & SigV4AuthSchemeIntegration
override val order: Byte = -60

// services which support SigV4A but don't model it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@
package aws.sdk.kotlin.codegen.customization.s3

import aws.sdk.kotlin.codegen.AwsRuntimeTypes
import software.amazon.smithy.aws.traits.auth.SigV4ATrait
import software.amazon.smithy.kotlin.codegen.KotlinSettings
import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolMiddleware
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.knowledge.ServiceIndex
import software.amazon.smithy.model.shapes.OperationShape

// FIXME: Remove this once sigV4a is supported by default AWS signer
/**
* Registers an interceptor for S3 to deal with the default signer not supporting sigV4a
* Registers an interceptor for sigV4a services to deal with the default signer not supporting sigV4a
* See: [aws.sdk.kotlin.runtime.http.interceptors.UnsupportedSigningAlgorithmInterceptor]
*/
class UnsupportedSigningAlgorithmIntegration : KotlinIntegration {
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
when (settings.sdkId.lowercase()) {
"s3", "eventbridge", "cloudfront keyvaluestore" -> true
else -> false
}
ServiceIndex
.of(model)
.getAuthSchemes(settings.service)
.values
.any { it.javaClass == SigV4ATrait::class.java }

override fun customizeMiddleware(
ctx: ProtocolGenerator.GenerationContext,
Expand Down
Loading