Skip to content

feat: policy add object tag#1908

Merged
overtrue merged 5 commits intorustfs:mainfrom
GatewayJ:fix/issuse-1874-policy-add-tag
Feb 27, 2026
Merged

feat: policy add object tag#1908
overtrue merged 5 commits intorustfs:mainfrom
GatewayJ:fix/issuse-1874-policy-add-tag

Conversation

@GatewayJ
Copy link
Member

Type of Change

  • New Feature
  • Bug Fix
  • Documentation
  • Performance Improvement
  • Test/CI
  • Refactor
  • Other:

Related Issues

Summary of Changes

#1874 (comment)

Checklist

  • I have read and followed the CONTRIBUTING.md guidelines
  • Passed make pre-commit
  • Added/updated necessary tests
  • Documentation updated (if needed)
  • CI/CD passed (if applicable)

Impact

  • Breaking change (compatibility)
  • Requires doc/config/deployment update
  • Other impact:

Additional Notes


Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for tag-based bucket policy conditions (specifically s3:ExistingObjectTag/<tag-key>) to enable per-object access control through bucket policies. This addresses issue #1874, which requested the ability to allow anonymous public access to specific objects in a bucket while keeping others private, based on object tags.

Changes:

  • Added get_object_tag_conditions_for_policy method to fetch and format object tags as policy condition values
  • Introduced ObjectTagConditions struct to pass tag conditions through the authorization flow
  • Integrated object tag condition evaluation into GetObject, HeadObject, and GetObjectAttributes authorization checks

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
rustfs/src/storage/ecfs.rs Added method to fetch object tags and format them as ExistingObjectTag conditions for policy evaluation
rustfs/src/storage/access.rs Added ObjectTagConditions struct and integrated tag condition fetching into authorization flow for GetObject, HeadObject, and GetObjectAttributes operations

@GatewayJ GatewayJ force-pushed the fix/issuse-1874-policy-add-tag branch 5 times, most recently from b96dcdd to 54f9e60 Compare February 25, 2026 14:46
@loverustfs loverustfs requested a review from Copilot February 26, 2026 02:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@GatewayJ GatewayJ force-pushed the fix/issuse-1874-policy-add-tag branch from 72bb5dc to f258118 Compare February 26, 2026 11:40
@GatewayJ GatewayJ requested a review from loverustfs February 26, 2026 12:02
GatewayJ and others added 2 commits February 27, 2026 14:47
…ject

Move req_info bucket/object/version_id update before fetch_tag_conditions
for consistency with other S3 operations (delete_object, get_object, etc.).
@GatewayJ GatewayJ force-pushed the fix/issuse-1874-policy-add-tag branch from f258118 to 821dfc1 Compare February 27, 2026 06:48
@loverustfs loverustfs requested a review from Copilot February 27, 2026 13:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

rustfs/src/storage/access.rs:610

  • In copy_object, after authorizing GetObject on the source with source object tags, the same ObjectTagConditions remain in req.extensions when authorizing PutObject on the destination. This means the destination PutObject authorization will incorrectly use the source object's tags in its policy conditions instead of no tags (since the destination doesn't exist yet) or the destination's tags (if copying to an existing object). Consider removing or replacing the tag conditions before the second authorization, or fetch destination tags if the destination object exists.
            let tag_conds = self
                .fetch_tag_conditions(&src_bucket, &src_key, version_id.as_deref(), "copy_object_src")
                .await?;
            req.extensions.insert(tag_conds);

            authorize_request(req, Action::S3Action(S3Action::GetObjectAction)).await?;
        }

        let req_info = req.extensions.get_mut::<ReqInfo>().expect("ReqInfo not found");

        req_info.bucket = Some(req.input.bucket.clone());
        req_info.object = Some(req.input.key.clone());
        req_info.version_id = req.input.version_id.clone();

        authorize_request(req, Action::S3Action(S3Action::PutObjectAction)).await

@overtrue overtrue merged commit 55396f1 into rustfs:main Feb 27, 2026
4 checks passed
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