Skip to content

Conversation

@alextwoods
Copy link
Contributor

@alextwoods alextwoods commented Mar 5, 2025

Description of changes:
Adds the Sigv4 AuthScheme to the AWS AuthIntegration and wires up the identity provider/auth params configs.

Generated Examples:

config.py:

@dataclass(init=False)
class Config:
    """Configuration for AmazonBedrockFrontendService."""
     # .... other properties
    aws_credentials_identity_resolver: (
        IdentityResolver[AWSCredentialIdentity, IdentityProperties] | None
    )
    region: str | None

auth.py:

@dataclass
class HTTPAuthParams:
    operation: str
    region: str | None


class HTTPAuthSchemeResolver:
    def resolve_auth_scheme(
        self, auth_parameters: HTTPAuthParams
    ) -> list[HTTPAuthOption]:
        auth_options: list[HTTPAuthOption] = []

        if (option := _generate_sigv4_option(auth_parameters)) is not None:
            auth_options.append(option)

        return auth_options


def _generate_sigv4_option(auth_params: HTTPAuthParams) -> HTTPAuthOption | None:
    return HTTPAuthOption(
        scheme_id="aws.auth#sigv4",
        identity_properties={},
        signer_properties={"service": "bedrock", "region": auth_params.region},
    )

client.py:

auth_parameters: HTTPAuthParams = HTTPAuthParams(
                operation=operation_name,
                region=config.region,
            )

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alextwoods alextwoods changed the title Sigv4 AuthScheme + wire up codegen Sigv4 AuthScheme + Static/Environment Credentials Providers Mar 5, 2025
@alextwoods alextwoods marked this pull request as ready for review March 6, 2025 19:56
@alextwoods alextwoods requested a review from a team as a code owner March 6, 2025 19:56
Comment on lines +84 to +85
// This needs to be generated because there's modeled parameters that
// must be accounted for.
Copy link
Contributor

Choose a reason for hiding this comment

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

Tragic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the alternative would be to add signingService as an auth param. We would then need a way to wire that up during the request. It could be an undocumented config property or have it somewhere else.

):
"""SigV4 AuthScheme."""

scheme_id: str
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
scheme_id: str
scheme_id: Final = "aws.auth#sigv4"

Well this should also be a ShapeID but that's probably a bit more involved to do just now.

Copy link
Contributor Author

@alextwoods alextwoods Mar 10, 2025

Choose a reason for hiding this comment

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

Yeah, I think we'd need to update the HttpAuthScheme protocol as well for that. I wasn't able to update this to Final without changing the HttpAuthScheme as well, which breaks with Final (since nothing is initialized on it).

For now, I've left the type as str but moved the initialization of it out of __init__

@alextwoods alextwoods merged commit c6fb91e into smithy-lang:develop Mar 11, 2025
2 checks passed
@alextwoods alextwoods deleted the codegen_sigv4_auth branch March 11, 2025 15:19
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.

4 participants