Skip to main content

Virtual bucket access policy

Access policy is applied to a Virtual Bucket and allows to control what operations can be performed on the bucket or objects within the bucket.

Policy rules​

A policy consists of a set of rules, each rule defines a list of conditions and an action.

Conditions are:

  • List of operations.

  • keyPattern - a POSIX wildcard pattern (such as folder1/*, *.mp4, or *.mp?) for an object key or prefix.

  • keyRegex (future versions) - a regular expression that an object key or prefix should match.

The list of operations in rule condition is simplified to include a set of related operations.

Rule condition operation

Included (matching) operations

HeadBucket

HeadBucket, GetBucketLocation, GetBucketVersioning, GetBucketAcl

ListObjects

ListObjects, ListObjectsV2 and ListObjectVersions

GetObject

GetObject, HeadObject, GetObjectAttributes, ListMultipartUploads, ListParts, GetObjectTagging, GetObjectRetention, GetObjectLegalHold

PutObject

PutObject, CopyObject, CreateMultipartUpload, UploadPart, UploadPartCopy, CompleteMultipartUpload, AbortMultipartUpload, PutObjectTagging, DeleteObjectTagging, PutObjectRetention, PutObjectLegalHold

RestoreObject

RestoreObject

DeleteObject

DeleteObject, DeleteObjects (for individual keys)

If the list of operations is empty or not defined, the rule applies to all operations.

keyPattern and keyRegex cannot be both defined at the same time. If both of them are not defined, empty, or null - the rule applies to all objects. The behavior of empty string patterns will change in the future: FL-2087

Operations on bucket (HeadBucket, etc.) do not have key or prefix option and match any keyPattern.

Actions are:

  • allowPublic - allows anyone (anonymous with no keys or user with correct HMAC keys) to perform this operation.

  • allow - allow authenticated user (with correct HMAC keys) to perform this operation. This is the default action if no rules are defined or apply.

  • fordbid- forbid (403 Forbidden response) this operation, even for correct HMAC keys.

Handling rules​

Policy rules are checked in order they are defined. An action of the first rule that has conditions satisfied is applied, and other rules are ignored.

The last implicit rule is always unconditional allow. In other words, if no rules are defined, all operations are allowed for an authenticated user (with correct HMAC keys) and forbidden for a anonymous public access (without HMAC keys).

For a virtual bucket, if request is anonymous (unsigned), it will only be sent to attached cloud bucket/container if the action is allowPublic. Otherwise, the requester will receive 403 Forbidden error. Anonymous requests are always denied for non-virtual buckets.

Examples​

Example 1

Rules:

  • pattern: folder1/*; action: allow

  • action: forbid

The user can do all operations (write, read, list) in folder1/ only. Operations with other prefixes (including HeadBucket) are forbidden.

Example 2

Rules:

  • Operation: GetObject, HeadBucket, GetBucketLocation; action: allowPublic

Bucket objects, metadata (HEAD) and location can be read anonymously (without providing HMAC keys). All other operations are allowed, but require authentication with HMAC keys.

Example 3

Rules:

  • Operation: PutObject; pattern: folder1/*; action: allow

  • Operation: PutObject; action: forbid

  • Operation: DeleteObject; action: forbid

If a user attempt to write object folder1/object.txt, it will be allowed because it matches the first rule. Writing objects folder2/object.txt or objects.txt will be forbidden because the first rule’s conditions are not satisfied and the 2nd rule applies. Deleting all objects will be forbidden (3rd rule), but reading and listing is allowed (default behavior express by the implicit last rule).

Known limitations and issues​

  • The bucket policy is applicable for virtual buckets only (not for storage account level buckets), and are separate from “allow write” and “allow delete” configuration for individual attached cloud buckets.

  • ListBuckets operation is always allowed for authenticated user and forbidden for anonymous user because it works on the virtual endpoint (not virtual bucket) level.

  • PutBucket and DeleteBucket operations are N/A because virtual buckets cannot be created or deleted via S3 API.

  • GetBucketAcl always return the same hardcoded response.