Skip to content

Commit d19fdfd

Browse files
authored
Merge pull request #8287 from shirady/nsfs-nc-doc-bucket-policy
NC | NSFS | Docs | Bucket Policy
2 parents 8b634dd + 6751d81 commit d19fdfd

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

docs/NooBaaNonContainerized/NooBaaCLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ The `bucket status` command is used to print the status of the bucket.
365365

366366
#### Usage
367367
```sh
368-
noobaa-cli bucket status --name <account_name>
368+
noobaa-cli bucket status --name <bucket_name>
369369
```
370370
#### Flags -
371371
- `name` (Required)

docs/NooBaaNonContainerized/S3Ops.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
1. [Overview](#overview)
55
2. [Supported S3 Bucket Operations](#supported-s3-bucket-operations)
66
3. [Supported S3 Object Operations](#supported-s3-object-operations)
7-
4. [Anonymous Requests Support](#anonymous-requests-support)
7+
4. [Bucket Policy Support](#bucket-policy-support)
8+
5. [Anonymous Requests Support](#anonymous-requests-support)
89

910
### Overview
1011

@@ -20,7 +21,10 @@ The following lists describe the bucket and object operations available in NooBa
2021
- S3 HeadBucket
2122
- S3 ListBuckets
2223
- S3 ListMultipartUploads
23-
24+
- S3 PutBucketPolicy
25+
- S3 DeleteBucketPolicy
26+
- S3 GetBucketPolicy
27+
- S3 GetBucketPolicyStatus
2428

2529
### Supported S3 Object Operations
2630

@@ -40,6 +44,56 @@ The following lists describe the bucket and object operations available in NooBa
4044
- S3 PutObjectTagging
4145
- S3 DeleteObjectTagging
4246

47+
### Bucket Policy Support
48+
- Bucket policies are an access policy option available to grant permission to buckets and objects (see [bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html) in AWS documentation). You can use bucket policies to add or deny permissions for the objects in a bucket. Bucket policies can allow or deny requests based on the elements in the policy.
49+
- Bucket policies use JSON-based policy language (for more information see [basic elements in bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html) in AWS documentation)
50+
- Bucket policy can be added to a bucket using the S3 API or the noobaa-cli.
51+
- Bucket policy is an additional layer of permissions to the FS permissions (UID and GID), which means that if two accounts do not have the same permissions (UID, GID) just setting bucket policy on the bucket is not enough.
52+
53+
#### Bucket Policy in NooBaa CLI
54+
1. Adding a bucket policy:
55+
- On bucket creation using the command: `noobaa-cli bucket add --name <bucket_name> --owner <owner_name> --path <path> --bucket_policy <bucket-policy>`.
56+
- On bucket update using the command: `noobaa-cli bucket update --name <bucket_name> --bucket_policy <bucket-policy>`.
57+
In both cases the argument for the bucket policy is a string
58+
2. Removing a bucket policy: `noobaa-cli bucket update --name <bucket_name> --bucket_policy ''` (using empty string)
59+
3. Get a bucket policy: `noobaa-cli bucket status --name <bucket_name>` (a bucket policy will be printed in the bucket details)
60+
61+
bucket_policy as a string example:
62+
`'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":["<account-name>"]},"Action":["s3:*"],"Resource":["arn:aws:s3:::<bucket-name>/*","arn:aws:s3:::<bucket-name>"]}]}'`
63+
64+
Replace `<account-name>` with account name and `<bucket-name>` with a bucket name.
65+
Note: `arn:aws:s3:::<bucket-name>` for S3 bucket operations and `arn:aws:s3:::<bucket-name>/*` for S3 object operations.
66+
Warning: this policy allows `<account-name>` to run all S3 operations.
67+
68+
#### Bucket Policy in S3 API (using AWS CLI)
69+
1. Adding bucket policy: `AWS_ACCESS_KEY_ID={access_key} AWS_SECRET_ACCESS_KEY={secret_key} aws s3api put-bucket-policy --endpoint-url {endpoint_address} --bucket {bucket_name} --policy file://policy.json`
70+
2. Removing a bucket policy: `AWS_ACCESS_KEY_ID={access_key} AWS_SECRET_ACCESS_KEY={secret_key} aws s3api delete-bucket-policy --endpoint-url {endpoint_address} --bucket {bucket_name} --policy file://policy.json`
71+
3. Get a bucket policy: `AWS_ACCESS_KEY_ID={access_key} AWS_SECRET_ACCESS_KEY={secret_key} aws s3api get-bucket-policy --endpoint-url {endpoint_address} --bucket {bucket_name} --policy file://policy.json`
72+
73+
policy.json example:
74+
```json
75+
{
76+
"Version": "2012-10-17",
77+
"Statement": [
78+
{
79+
"Effect": "Allow",
80+
"Principal": { "AWS": [ "<account-name>" ] },
81+
"Action": [ "s3:*" ],
82+
"Resource": [ "arn:aws:s3:::<bucket-name>/*", "arn:aws:s3:::<bucket-name>" ]
83+
}
84+
]
85+
}
86+
```
87+
Replace `<account-name>` with account name and `<bucket-name>` with a bucket name.
88+
Note: `arn:aws:s3:::<bucket-name>` for S3 bucket operations and `arn:aws:s3:::<bucket-name>/*` for S3 object operations.
89+
Warning: this policy allows `<account-name>` to run all S3 operations.
90+
91+
##### Principal Field:
92+
A bucket policy defines which principals can perform actions on the bucket. The Principal element specifies the user or account that is either allowed or denied access to a resource.
93+
Currently we support a couple of options:
94+
1. Grant anonymous permissions (all principals): either `"Principal": { "AWS": "*" }` or `"Principal": { "*" }`.
95+
2. Principal by account name: `"Principal": { "AWS": [ "<account-name-1>", "<account-name-2>", ... ,"<account-name-n>"] }`
96+
4397
### Anonymous Requests Support
4498

4599
Anonymous requests are S3 requests made without an access key or a secret key -

0 commit comments

Comments
 (0)