Skip to content

Commit

Permalink
Add @optionalAuth to all S3 operations (#2955)
Browse files Browse the repository at this point in the history
In #2907, I created an allow list of S3 operations to add
`@optionalAuth` to, but this turns out to be too restrictive, as seen in
awslabs/aws-sdk-rust#878. This PR restores the
original middleware behavior of allowing optional auth for all S3
operations.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
jdisanti authored Aug 29, 2023
1 parent 2653bf8 commit 9f39607
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ message = "Update MSRV to Rust 1.70.0"
references = ["smithy-rs#2948"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" }
author = "Velfi"

[[aws-sdk-rust]]
message = "Allow `no_credentials` to be used with all S3 operations."
references = ["smithy-rs#2955", "aws-sdk-rust#878"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "jdisanti"
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,9 @@ class FilterEndpointTests(

// TODO(P96049742): This model transform may need to change depending on if and how the S3 model is updated.
private class AddOptionalAuth {
private val s3OptionalAuthOperations = listOf(
ShapeId.from("com.amazonaws.s3#ListObjects"),
ShapeId.from("com.amazonaws.s3#ListObjectsV2"),
ShapeId.from("com.amazonaws.s3#HeadObject"),
ShapeId.from("com.amazonaws.s3#GetObject"),
)

fun transform(model: Model) = ModelTransformer.create().mapShapes(model) { shape ->
if (shape is OperationShape && s3OptionalAuthOperations.contains(shape.id) && !shape.hasTrait<OptionalAuthTrait>()) {
// Add @optionalAuth to all S3 operations
if (shape is OperationShape && !shape.hasTrait<OptionalAuthTrait>()) {
shape.toBuilder()
.addTrait(OptionalAuthTrait())
.build()
Expand Down

0 comments on commit 9f39607

Please sign in to comment.