@@ -61,3 +61,106 @@ Note: Currently we clean the cache after update, but it happens for the specific
61
61
3 . Use the root accounts manager account credentials to create a root account:
62
62
` nc-user-manager-iam create-user --user-name <username> `
63
63
4 . Use the root account credentials to create access keys for the root account: ` nc-user-manager-iam iam create-access-key --user-name <username> `
64
+
65
+ #### One Account With 2 Users With Bucket Policy
66
+ Note: Currently we have implementation of the Principal field as name or ID in NC - not with ARN at this point, so we will use what we currently have in this example (we can support it in the future).
67
+
68
+ ##### Basic steps (create account and bucket and check connection to endpoint)
69
+ 1 . Create an account with noobaa CLI: ` sudo node src/cmd/manage_nsfs account add --name <account-name> --new_buckets_path /Users/buckets/ --access_key <access-key> --secret_key <secret-key> --uid <uid> --gid <gid> `
70
+ Note: before creating the account need to give permission to the ` new_buckets_path ` : ` chmod 777 /Users/buckets/ ` .
71
+ 2 . Start the NSFS server (using debug mode and the port for IAM): ` sudo node src/cmd/nsfs --debug 5 --https_port_iam 7005 `
72
+ 3 . Create the alias for S3 service:` alias nc-user-1-s3=‘AWS_ACCESS_KEY_ID=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:6443’ ` .
73
+ 4 . Check the connection to the endpoint and try to list the buckets (should be empty): ` nc-user-1-s3 s3 ls; echo $? `
74
+ 5 . Add bucket to the account using AWS CLI: ` nc-user-1-s3 s3 mb s3://bucket-01 ` (` bucket-01 ` is the bucket name in this example) or noobaa CLI: ` sudo node src/cmd/manage_nsfs bucket add --name bucket-01 --path /Users/buckets/bucket-01 --owner <account-name> `
75
+ 6 . Create the alias for IAM service:
76
+ ` alias nc-user-1-iam='AWS_ACCESS_KEY_ID=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:7005' `
77
+ 7 . Check the connection to the endpoint and try to list the users (should be empty): ` nc-user-1-iam iam list-users `
78
+
79
+ ##### IAM steps (create 3 users with access keys)
80
+ We will create 3 users:
81
+ (1) user for read-write permission user-rw
82
+ (2) user for read permission user-ro
83
+ (3) user without any permission user-no
84
+
85
+ We will give example of user-rw, but it is the same for the rest
86
+ 8 . Create user: ` nc-user-1-iam iam create-user --user-name user-rw `
87
+ 9 . Create access key for user user-rw: ` nc-user-1-iam iam create-access-key --user-name user-rw `
88
+ 10 . Create alias for S3 service:` alias nc-user-rw-s3=‘AWS_ACCESS_KEY_ID=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:6443’ ` .
89
+ 11 . Check the connection to the endpoint and try to list the buckets (should be one): ` nc-user-rw-s3 s3 ls; echo $? `
90
+
91
+ we will have 3 alias: ` nc-user-rw-s3 ` , ` nc-user-ro-s3 ` , ` nc-user-no-s3 `
92
+
93
+ ##### S3 steps (bucket policy and s3 operations)
94
+ 12 . Root account will put the bucket policy - ` nc-user-1-s3 s3api put-bucket-policy --bucket bucket-01 --policy file://policy.json `
95
+
96
+ policy with IDs (can be done in master branch)
97
+
98
+ ``` json
99
+ {
100
+ "Version" : " 2012-10-17" ,
101
+ "Statement" : [
102
+ {
103
+ "Sid" : " AllowUserRW" ,
104
+ "Effect" : " Allow" ,
105
+ "Principal" : { "AWS" : [ " <id of user-rw>" ] },
106
+ "Action" : [ " s3:PutObject" , " s3:GetObject" , " s3:ListBucket" ],
107
+ "Resource" : [ " arn:aws:s3:::bucket-01/*" , " arn:aws:s3:::bucket-01" ]
108
+ },
109
+ {
110
+ "Sid" : " AllowUserRO" ,
111
+ "Effect" : " Allow" ,
112
+ "Principal" : { "AWS" : [ " id of user-ro" ] },
113
+ "Action" : [ " s3:GetObject" , " s3:ListBucket" ],
114
+ "Resource" : [ " arn:aws:s3:::bucket-01/*" , " arn:aws:s3:::bucket-01" ]
115
+ }
116
+ ]
117
+ }
118
+ ```
119
+
120
+ policy with names (can be done in version 5.17)
121
+
122
+ ```
123
+ {
124
+ "Version": "2012-10-17",
125
+ "Statement": [
126
+ {
127
+ "Sid": "AllowUserRW",
128
+ "Effect": "Allow",
129
+ "Principal": { "AWS": [ "user-rw" ] },
130
+ "Action": [ "s3:PutObject", "s3:GetObject", "s3:ListBucket" ],
131
+ "Resource": [ "arn:aws:s3:::bucket-01/*", "arn:aws:s3:::bucket-01" ]
132
+ },
133
+ {
134
+ "Sid": "AllowUserRO",
135
+ "Effect": "Allow",
136
+ "Principal": { "AWS": [ "user-ro" ] },
137
+ "Action": [ "s3:GetObject", "s3:ListBucket"],
138
+ "Resource": [ "arn:aws:s3:::bucket-01/*", "arn:aws:s3:::bucket-01" ]
139
+ }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ user user-rw:
145
+ 13 . user-rw can put object: ` echo 'hello_world1' | nc-user-rw-s3 s3 cp - s3://bucket-01/hello_world1.txt #valid `
146
+ 14 . user-rw can get object: ` nc-user-rw-s3 s3api get-object --bucket bucket-01 --key hello_world1.txt /dev/stdout `
147
+ 15 . user-rw can list the objects in the bucket: ` nc-user-rw-s3 s3api list-objects-v2 --bucket bucket-01 ` (expected to see ` hello_world1.txt ` )
148
+
149
+ user user-ro:
150
+ 16 . user-ro cannot put object: ` echo 'hello_world2' | nc-user-ro-s3 s3 cp - s3://bucket-01/hello_world2.txt #invalid ` (` AccessDenied ` error)
151
+ 17 . user-ro can get object: ` nc-user-ro-s3 s3api get-object --bucket bucket-01 --key hello_world1.txt /dev/stdout `
152
+ 18 . user-ro can list the objects in the bucket: ` nc-user-ro-s3 s3api list-objects-v2 --bucket bucket-01 ` (expected to see ` hello_world1.txt ` )
153
+
154
+ user user-no: (all should fail with ` AccessDenied ` error)
155
+ 20 . user-no cannot put object: ` echo 'hello_world3' | nc-user-no-s3 s3 cp - s3://bucket-01/hello_world3.txt #invalid ` (` AccessDenied ` error)
156
+ 21 . user-no cannot get object: ` nc-user-no-s3 s3api get-object --bucket bucket-01 --key hello_world1.txt /dev/stdout ` (` AccessDenied ` error)
157
+ 22 . user-no cannot list the objects in the bucket: ` nc-user-no-s3 s3api list-objects-v2 --bucket bucket-01 ` (` AccessDenied ` error)
158
+
159
+ ##### Expend the example (additional account and a user inside it)
160
+ 23 . Add another account with noobaa CLI - see step 1 and create alias ` nc-user-2-iam `
161
+ 24 . Add user ` acc2-user ` with access key and create alias ` nc-user-acc2-user-s3 ` - see steps 8-10
162
+ 25 . Run the operations:
163
+ user uacc2-user: (all should fail with ` AccessDenied ` error)
164
+ 26 . user-no cannot put object: ` echo 'hello_world4' | nc-user-acc2-user-s3 s3 cp - s3://bucket-01/hello_world4.txt #invalid ` (` AccessDenied ` error)
165
+ 27 . user-no cannot get object: ` nc-user-acc2-user-s3 s3api get-object --bucket bucket-01 --key hello_world1.txt /dev/stdout ` (` AccessDenied ` error)
166
+ 28 . user-no cannot list the objects in the bucket: ` nc-user-acc2-user-s3 s3api list-objects-v2 --bucket bucket-01 ` (` AccessDenied ` error)
0 commit comments