Skip to content

Commit 13b9f15

Browse files
committed
IAM | Change Default Behavior of Users Without IAM User Policy
Signed-off-by: shirady <[email protected]>
1 parent d3c091e commit 13b9f15

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

docs/design/IamUserInlinePolicy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ When used, it adds a layer of permission to the users under the account.
44
We decided that IAM user inline policies are checked for authorization only in S3 operations (`src/endpoint/s3/s3_rest.js`).
55

66
## User Without IAM User Policy
7-
We decided that when a user is created under the account (and has access keys), it can operate all S3 operations (unless there is a bucket policy which do not authorize it).
7+
User must have IAM policy to be authorized for S3 operations.
88

99
## User With IAM User Policy
1010
The user’s inline policy is embedded in the user.
@@ -29,8 +29,8 @@ If a user has a user policy, the ability to perform an S3 operation is based on
2929
For every S3 request, authorization (`authorize_request` in `src/endpoint/s3/s3_rest.js`) is performed.
3030
The authorization now will have:
3131
1. Authorization handle for signed request and anonymous requests.
32-
2. Authorization handle according to bucket policy.
33-
3. Authorization handle according to the user IAM policy (the new added layer - only for IAM users).
32+
2. Authorization handle according to the user IAM policy (the new added layer - only for IAM users).
33+
3. Authorization handle according to bucket policy.
3434

3535
If one of the layers does not permit it would result in `AccessDenied` error.
3636

src/endpoint/s3/s3_rest.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,11 @@ function authenticate_request(req) {
220220

221221
async function authorize_request(req) {
222222
await req.object_sdk.load_requesting_account(req);
223-
await Promise.all([
224-
req.object_sdk.authorize_request_account(req),
225-
// authorize_request_policy(req) is supposed to
226-
// allow owners access unless there is an explicit DENY policy
227-
authorize_request_policy(req),
228-
// authorize_request_iam_policy(req) is for users only
229-
authorize_request_iam_policy(req),
230-
]);
223+
await req.object_sdk.authorize_request_account(req);
224+
await authorize_request_iam_policy(req); // authorize_request_iam_policy(req) is for users only
225+
// authorize_request_policy(req) is supposed to
226+
// allow owners access unless there is an explicit DENY policy
227+
await authorize_request_policy(req);
231228
}
232229

233230
async function authorize_request_policy(req) {
@@ -336,6 +333,7 @@ async function authorize_request_policy(req) {
336333
throw new S3Error(S3Error.AccessDenied);
337334
}
338335

336+
// TODO - move the function and throw message error with details
339337
async function authorize_request_iam_policy(req) {
340338
const auth_token = req.object_sdk.get_auth_token();
341339
const is_anonymous = !(auth_token && auth_token.access_key);
@@ -348,7 +346,7 @@ async function authorize_request_iam_policy(req) {
348346
const resource_arn = _get_arn_from_req_path(req);
349347
const method = _get_method_from_req(req);
350348
const iam_policies = account.iam_user_policies || [];
351-
if (iam_policies.length === 0) return;
349+
if (iam_policies.length === 0 && req.object_sdk.nsfs_config_root) return; // We do not have IAM policies in NC yet
352350

353351
// parallel policy check
354352
const promises = [];

0 commit comments

Comments
 (0)