Skip to content

Conversation

@jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Jul 30, 2025

Description of changes

Supports the changes to internal clients in awslabs/aws-sdk-swift#1995 .

  • Adds a protocol that can be added to credential resolver types to signify that a credential resolver was not customer-supplied.
  • Adds implementations of that protocol to the static identity resolver types.
  • Adds an internalClient Boolean field to SwiftSettings, to help make codegen code more clear.
  • Adds awareness of the package keyword introduced to Swift in Swift 5.9.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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

val mergeModels: Boolean,
val copyrightNotice: String,
val visibility: String,
val internalClient: Boolean,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this internalClient field to SwiftSettings to help make codegen more clear, i.e. can query this setting directly rather than rely on some string value of visibility.

*/
enum class AccessModifier {
Public,
PublicPrivateSet,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of Swift 5.9 package is a Swift access modifier or "visibility" level.

Adding it to this enum along with the existing levels.

"operator",
"optional",
"override",
"package",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding package as a Swift reserved word so that it gets escaped with backticks in generated code.

There actually do seem to be services that already use package as an identifier without escaping it, but to date it seems not to cause any problems.

val BearerTokenIdentity = runtimeSymbol("BearerTokenIdentity", SwiftDeclaration.STRUCT)
val StaticBearerTokenIdentityResolver = runtimeSymbol("StaticBearerTokenIdentityResolver", SwiftDeclaration.STRUCT)
val ClientConfigDefaultBearerTokenIdentityResolver =
runtimeSymbol("ClientConfigDefaultBearerTokenIdentityResolver", SwiftDeclaration.STRUCT)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Symbol for the ClientConfigDefaultBearerTokenIdentityResolver defined at top.

@jbelkins jbelkins marked this pull request as ready for review July 31, 2025 16:53
@jbelkins jbelkins requested review from dayaffe and sichanyoo July 31, 2025 16:54
Copy link
Contributor

@sichanyoo sichanyoo left a comment

Choose a reason for hiding this comment

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

A suggestion on ClientConfigDefaultBearerTokenIdentityResolver

public struct StaticAWSCredentialIdentityResolver: AWSCredentialIdentityResolver {
private let credentials: AWSCredentialIdentity
fileprivate let credentials: AWSCredentialIdentity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The @_spi initializer below creates a AWS credential identity resolver with empty credentials. This is used in internal clients, where the default AWS credential identity resolver is never used.

return credentials
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ClientConfigDefaultIdentityResolver extension below marks this resolver as a client config default if the credentials are empty, something that the new initializer above does, but a real customer should never do.

// SPDX-License-Identifier: Apache-2.0
//

@_spi(ClientConfigDefaultIdentityResolver) import protocol SmithyIdentityAPI.ClientConfigDefaultIdentityResolver
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty much the same changes in this StaticBearerTokenIdentityResolver as in the StaticAWSCredentialIdentityResolver just above.

/// A protocol on identity resolver used to signify that this resolver is a default resolver created because the client config was not passed a custom resolver at creation.
///
/// Resolvers that do not implement this protocol should be presumed to not be a client config default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The protocol below is used to determine if a credential resolver came from client config defaults. It's protected with @_spi so it isn't visible to customers.

private fun runtimeSymbol(
name: String,
declaration: SwiftDeclaration?,
additionalImports: List<Symbol> = emptyList(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just fixed a typo in this file

@sichanyoo sichanyoo self-requested a review August 4, 2025 21:51
@jbelkins jbelkins merged commit 2376b5a into main Aug 4, 2025
33 checks passed
@jbelkins jbelkins deleted the jbe/identity_client_inject branch August 4, 2025 21:55
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.

2 participants