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

feat: tie up some loose ends #645

Merged
merged 3 commits into from
Jan 16, 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 @@ -6,16 +6,16 @@
//

public struct DefaultIdentityResolverConfiguration: IdentityResolverConfiguration {
let credentialsProvider: (any IdentityResolver)?
let credentialsProvider: Attributes

public init(configuredIdResolvers: Attributes) {
self.credentialsProvider = configuredIdResolvers.get(key: AttributeKeys.awsIdResolver) ?? nil
self.credentialsProvider = configuredIdResolvers
}

func getIdentityResolver(identityKind: IdentityKind) -> (any IdentityResolver)? {
switch identityKind {
case .aws:
return self.credentialsProvider
return self.credentialsProvider.get(key: AttributeKeys.awsIdResolver)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class AuthSchemeResolverGenerator {
// endpoint resolver's auth scheme resolution to resolve an auth scheme.
renderEndpointParamFields(ctx, this)
} else {
// If service supports SigV4 auth scheme, it's a special-case for now - change once sigv4a trait is added
// and it becomes possible at model level to notate custom members for a given auth scheme.
// If service supports SigV4/SigV4a auth scheme, it's a special-case for now - change once
// it becomes possible at model level to notate custom members for a given auth scheme.
// Region has to be in params in addition to operation string.
if (serviceIndex.getEffectiveAuthSchemes(ctx.service).contains(SigV4Trait.ID)) {
write("// Region is used for SigV4 auth scheme")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object ClientRuntimeTypes {
val RetryMiddleware = runtimeSymbol("RetryMiddleware")
val IdempotencyTokenMiddleware = runtimeSymbol("IdempotencyTokenMiddleware")
val NoopHandler = runtimeSymbol("NoopHandler")
val SigningMiddleware = runtimeSymbol("SignerMiddleware")
val SignerMiddleware = runtimeSymbol("SignerMiddleware")
val AuthSchemeMiddleware = runtimeSymbol("AuthSchemeMiddleware")
val BodyMiddleware = runtimeSymbol("BodyMiddleware")
val PayloadBodyMiddleware = runtimeSymbol("PayloadBodyMiddleware")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import software.amazon.smithy.swift.codegen.integration.middlewares.OperationInp
import software.amazon.smithy.swift.codegen.integration.middlewares.OperationInputUrlHostMiddleware
import software.amazon.smithy.swift.codegen.integration.middlewares.OperationInputUrlPathMiddleware
import software.amazon.smithy.swift.codegen.integration.middlewares.RetryMiddleware
import software.amazon.smithy.swift.codegen.integration.middlewares.SigningMiddleware
import software.amazon.smithy.swift.codegen.integration.middlewares.SignerMiddleware
import software.amazon.smithy.swift.codegen.integration.middlewares.providers.HttpHeaderProvider
import software.amazon.smithy.swift.codegen.integration.middlewares.providers.HttpQueryItemProvider
import software.amazon.smithy.swift.codegen.integration.middlewares.providers.HttpUrlPathProvider
Expand Down Expand Up @@ -465,7 +465,7 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
operationMiddleware.appendMiddleware(operation, LoggingMiddleware(ctx.model, ctx.symbolProvider))
operationMiddleware.appendMiddleware(operation, RetryMiddleware(ctx.model, ctx.symbolProvider, retryErrorInfoProviderSymbol))

operationMiddleware.appendMiddleware(operation, SigningMiddleware(ctx.model, ctx.symbolProvider))
operationMiddleware.appendMiddleware(operation, SignerMiddleware(ctx.model, ctx.symbolProvider))

addProtocolSpecificMiddleware(ctx, operation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package software.amazon.smithy.swift.codegen.integration

import software.amazon.smithy.aws.traits.auth.SigV4ATrait
import software.amazon.smithy.aws.traits.auth.SigV4Trait
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.knowledge.ServiceIndex
Expand Down Expand Up @@ -45,6 +46,9 @@ open class HttpProtocolServiceClient(
if (ServiceIndex(ctx.model).getEffectiveAuthSchemes(ctx.service).contains(SigV4Trait.ID)) {
writer.write("modeledAuthSchemes.append(SigV4AuthScheme())")
}
if (ServiceIndex(ctx.model).getEffectiveAuthSchemes(ctx.service).contains(SigV4ATrait.ID)) {
writer.write("modeledAuthSchemes.append(SigV4AAuthScheme())")
}
writer.write("config.authSchemes = config.authSchemes ?? modeledAuthSchemes")
writer.write("self.config = config")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import software.amazon.smithy.swift.codegen.middleware.MiddlewarePosition
import software.amazon.smithy.swift.codegen.middleware.MiddlewareRenderable
import software.amazon.smithy.swift.codegen.middleware.MiddlewareStep

class SigningMiddleware(
class SignerMiddleware(
val model: Model,
val symbolProvider: SymbolProvider
) : MiddlewareRenderable {
Expand All @@ -31,7 +31,7 @@ class SigningMiddleware(
val outputError = MiddlewareShapeUtils.outputErrorSymbol(op)
writer.write(
"$operationStackName.${middlewareStep.stringValue()}.intercept(position: ${position.stringValue()}, middleware: \$N<\$N, \$N>())",
ClientRuntimeTypes.Middleware.SigningMiddleware, output, outputError
ClientRuntimeTypes.Middleware.SignerMiddleware, output, outputError
)
}
}
Loading