Skip to content

Commit

Permalink
Use resolver chain only if service actually uses HTTP bearer auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sichan Yoo committed Jul 26, 2024
1 parent a37a5da commit a5c7f28
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package software.amazon.smithy.aws.swift.codegen

import software.amazon.smithy.aws.swift.codegen.swiftmodules.AWSSDKIdentityTypes
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.knowledge.ServiceIndex
import software.amazon.smithy.model.traits.HttpBearerAuthTrait
import software.amazon.smithy.swift.codegen.AuthSchemeResolverGenerator
import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.config.ConfigProperty
Expand Down Expand Up @@ -50,12 +52,16 @@ class AWSHttpProtocolServiceClient(
ConfigProperty("authSchemes", SmithyHTTPAuthAPITypes.AuthSchemes.toOptional(), AWSAuthUtils(ctx).authSchemesDefaultProvider)
}
"bearerTokenIdentityResolver" -> {
ConfigProperty(
"bearerTokenIdentityResolver",
SmithyIdentityTypes.BearerTokenIdentityResolver.toGeneric(),
{ it.format("\$N()", AWSSDKIdentityTypes.DefaultBearerTokenIdentityResolverChain) },
true
)
if (ServiceIndex(ctx.model).getEffectiveAuthSchemes(ctx.service).contains(HttpBearerAuthTrait.ID)) {
ConfigProperty(
"bearerTokenIdentityResolver",
SmithyIdentityTypes.BearerTokenIdentityResolver.toGeneric(),
{ it.format("\$N()", AWSSDKIdentityTypes.DefaultBearerTokenIdentityResolverChain) },
true
)
} else {
it
}
}
"retryStrategyOptions" -> {
ConfigProperty(
Expand Down

0 comments on commit a5c7f28

Please sign in to comment.