durch / rust-s3

Rust library for interfacing with S3 API compatible services
MIT License
498 stars 195 forks source link

Add custome access policy #317

Closed pcoves closed 1 year ago

pcoves commented 1 year ago

Is your feature request related to a problem? Please describe.

I'm looking for a way to make a directory public in a private minio bucket.

I can make it so using wc by hand. Also by browsing through minio console and add a readonly with prefix authorization.

Describe the solution you'd like

I'd love to be able to set a custom access policy.

I did not find how to do it. Maybe is this already available? If so, is there an example somewhere?

Describe alternatives you've considered

I really the access policy is the only and best way to handle this issue.

Additional context

Here is the policy I get while using the GUI:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::ce2c9e50-e61a-4d6c-9b3b-57b6a22f2597"
            ]
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::ce2c9e50-e61a-4d6c-9b3b-57b6a22f2597"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "public/"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::ce2c9e50-e61a-4d6c-9b3b-57b6a22f2597/public/*"
            ]
        }
    ]
}