Skip to content
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 @@ -222,6 +222,8 @@ class RulesBasedAuthSchemeResolverGenerator {
)
}

writer.write("let authSchemePreference = context.getAuthSchemePreference()")

// Copy over endpoint param fields to auth param fields
val ruleSetNode = ctx.service.getTrait<EndpointRuleSetTrait>()?.ruleSet
val ruleSet = if (ruleSetNode != null) EndpointRuleSet.fromNode(ruleSetNode) else null
Expand All @@ -234,7 +236,7 @@ class RulesBasedAuthSchemeResolverGenerator {
}

val argStringToAppend = if (paramList.isEmpty()) "" else ", " + paramList.joinToString()
write("return $returnTypeName(operation: opName$argStringToAppend)")
write("return $returnTypeName(authSchemePreference: authSchemePreference, operation: opName$argStringToAppend)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class RulesBasedAuthSchemeResolverGeneratorTests {
contents.shouldSyntacticSanityCheck()
val expectedContents = """
public struct S3AuthSchemeResolverParameters: SmithyHTTPAuthAPI.AuthSchemeResolverParameters {
public let authSchemePreference: [String]?
public let operation: Swift.String
}

Expand All @@ -32,12 +33,6 @@ public protocol S3AuthSchemeResolver: SmithyHTTPAuthAPI.AuthSchemeResolver {

private struct InternalModeledS3AuthSchemeResolver: S3AuthSchemeResolver {

public let authSchemePreference: [String]

public init(authSchemePreference: [String] = []) {
self.authSchemePreference = authSchemePreference
}

public func resolveAuthScheme(params: SmithyHTTPAuthAPI.AuthSchemeResolverParameters) throws -> [SmithyHTTPAuthAPI.AuthOption] {
var validAuthOptions = [SmithyHTTPAuthAPI.AuthOption]()
guard let serviceParams = params as? S3AuthSchemeResolverParameters else {
Expand Down Expand Up @@ -140,7 +135,7 @@ private struct InternalModeledS3AuthSchemeResolver: S3AuthSchemeResolver {
sigv4Option.identityProperties.set(key: AWSSDKIdentity.InternalClientKeys.internalSSOOIDCClientKey, value: InternalAWSSSOOIDC.IdentityProvidingSSOOIDCClient())
validAuthOptions.append(sigv4Option)
}
return self.reprioritizeAuthOptions(authSchemePreference: authSchemePreference, authOptions: validAuthOptions)
return self.reprioritizeAuthOptions(authSchemePreference: serviceParams.authSchemePreference, authOptions: validAuthOptions)
}

public func constructParameters(context: Smithy.Context) throws -> SmithyHTTPAuthAPI.AuthSchemeResolverParameters {
Expand Down Expand Up @@ -200,7 +195,8 @@ public struct DefaultS3AuthSchemeResolver: S3AuthSchemeResolver {
guard let endpointParam = context.get(key: Smithy.AttributeKey<EndpointParams>(name: "EndpointParams")) else {
throw Smithy.ClientError.dataNotFound("Endpoint param not configured in middleware context for rules-based auth scheme resolver params construction.")
}
return S3AuthSchemeResolverParameters(operation: opName)
let authSchemePreference = context.getAuthSchemePreference()
return S3AuthSchemeResolverParameters(authSchemePreference: authSchemePreference, operation: opName)
}
}
"""
Expand Down
Loading