Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PutBucketACL: unable to remove current grants #861

Closed
evgeniiz321 opened this issue Oct 18, 2023 · 5 comments · Fixed by #995
Closed

PutBucketACL: unable to remove current grants #861

evgeniiz321 opened this issue Oct 18, 2023 · 5 comments · Fixed by #995
Assignees
Labels
bug Something isn't working I4 No visible changes S4 Routine U3 Regular
Milestone

Comments

@evgeniiz321
Copy link

Current grants:

'Owner': {'DisplayName': 'NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM', 'ID': 'NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM'}, 
'Grants': [
{'Grantee': {'DisplayName': '', 'EmailAddress': '', 'ID': '031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a', 'Type': 'CanonicalUser', 'URI': ''}, 'Permission': 'FULL_CONTROL'}]}

We want to remove Grants and trying to PUT following json:

{'Owner': {'DisplayName': 'NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM', 'ID': 'NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM'}, 'Grants': []}

But get 500:

2023-10-18T02:18:11.257Z        error   handler/util.go:29      call method     {"status": 500, "request_id": "fc0c14a1-f3e5-4c21-93d5-d066f798bd19", "method": "PutBucketACL", "bucket": "yournamehere-5glkzt0jx74e55ha-1", "object": "", "description": "could not update bucket acl", "error": "could not translate ast to table: form records: public key from string: encoding/hex: invalid byte: U+004E 'N'"}
@evgeniiz321 evgeniiz321 added bug Something isn't working triage labels Oct 18, 2023
@roman-khimov roman-khimov added this to the v0.30.0 milestone Oct 18, 2023
@smallhive
Copy link
Contributor

smallhive commented Oct 31, 2023

The main problem here is the gate ACL response

$ aws --no-paginate s3api get-bucket-acl --bucket $BUCKET --endpoint http://localhost:19080
{
    "Owner": {
        "DisplayName": "Nj9FF9jYTsyX2XniTw5Kqy3Zf91nbhdYiM",
        "ID": "Nj9FF9jYTsyX2XniTw5Kqy3Zf91nbhdYiM"
    },
    "Grants": [
        {
            "Grantee": {
                "DisplayName": "Nj9FF9jYTsyX2XniTw5Kqy3Zf91nbhdYiM",
                "ID": "033845e8ebc78251029261cbc0e9bae104d2b7cc9fee5c79720a30332d5b3d1aa0",
                "Type": "CanonicalUser"
            },
            "Permission": "FULL_CONTROL"
        }
    ]
}

Here in Owner.ID and Owner.DisplayName we put the wallet address. This is the only available information from the bucket about the owner.

Owner.ID should have the owner's public key, like in the Grantee section, to execute such set-acl requests without canned rules.
Generally, we would take this info from the bearer token and pass it through. But in the case of an anonymous request, we just don't have the source to derive this information.

The first thought that came to my mind is putting the owner public key to container attributes. But what if a container was created without s3 gate? It means the side system will not add the required information to the attributes.
We need a way to get the bucket owner public key in any time.

About the issue in general, does it make sense to restrict yourself to the bucket?

@roman-khimov
Copy link
Member

Let's try container attributes (forget about non-S3 containers) until we have nspcc-dev/neofs-api#278.

@roman-khimov roman-khimov added U3 Regular S4 Routine I4 No visible changes and removed triage labels Dec 20, 2023
@roman-khimov
Copy link
Member

Needs to be checked against the AWS, any behavior can be justified.

@roman-khimov roman-khimov modified the milestones: v0.30.0, v0.30.1 Mar 25, 2024
@roman-khimov roman-khimov modified the milestones: v0.30.1, v0.31.0 Jun 18, 2024
@roman-khimov roman-khimov modified the milestones: v0.31.0, v0.31.1 Jul 22, 2024
@roman-khimov
Copy link
Member

We've got new tokens with addresses, maybe something can be improved here.

@smallhive smallhive self-assigned this Sep 3, 2024
smallhive added a commit that referenced this issue Sep 3, 2024
Closes #861.

Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
@smallhive
Copy link
Contributor

After the latest changes, the GRANTS look different and consistent:

{
    "Owner": {
        "DisplayName": "NiskPF9pfRMzg7V7PeB4d6ogLzu74a1L2Q",
        "ID": "NiskPF9pfRMzg7V7PeB4d6ogLzu74a1L2Q"
    },
    "Grants": [
        {
            "Grantee": {
                "DisplayName": "NiskPF9pfRMzg7V7PeB4d6ogLzu74a1L2Q",
                "ID": "NiskPF9pfRMzg7V7PeB4d6ogLzu74a1L2Q",
                "Type": "CanonicalUser"
            },
            "Permission": "FULL_CONTROL"
        }
    ]
}

Now it is possible to upload downloaded ACL grants to the bucket without error. For test I used the next script:

export BUCKET=heh$(date +%s); echo $BUCKET; aws s3api create-bucket --bucket $BUCKET --endpoint http://localhost:19080
aws s3api get-bucket-acl --bucket $BUCKET --endpoint-url http://localhost:19080 > ACL.json
aws s3api put-bucket-acl --bucket $BUCKET --endpoint-url http://localhost:19080 --access-control-policy file://ACL.json

Despite this, it has no effect on the bucket owner grants. There is impossible to remove GRANTS from container owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working I4 No visible changes S4 Routine U3 Regular
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants