Skip to content

Commit 39ed7aa

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

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
@@ -217,14 +217,11 @@ function authenticate_request(req) {
217217

218218
async function authorize_request(req) {
219219
await req.object_sdk.load_requesting_account(req);
220-
await Promise.all([
221-
req.object_sdk.authorize_request_account(req),
222-
// authorize_request_policy(req) is supposed to
223-
// allow owners access unless there is an explicit DENY policy
224-
authorize_request_policy(req),
225-
// authorize_request_iam_policy(req) is for users only
226-
authorize_request_iam_policy(req),
227-
]);
220+
await req.object_sdk.authorize_request_account(req);
221+
await authorize_request_iam_policy(req); // authorize_request_iam_policy(req) is for users only
222+
// authorize_request_policy(req) is supposed to
223+
// allow owners access unless there is an explicit DENY policy
224+
await authorize_request_policy(req);
228225
}
229226

230227
async function authorize_request_policy(req) {
@@ -333,6 +330,7 @@ async function authorize_request_policy(req) {
333330
throw new S3Error(S3Error.AccessDenied);
334331
}
335332

333+
// TODO - move the function and throw message error with details
336334
async function authorize_request_iam_policy(req) {
337335
const auth_token = req.object_sdk.get_auth_token();
338336
const is_anonymous = !(auth_token && auth_token.access_key);
@@ -345,7 +343,7 @@ async function authorize_request_iam_policy(req) {
345343
const resource_arn = _get_arn_from_req_path(req);
346344
const method = _get_method_from_req(req);
347345
const iam_policies = account.iam_user_policies || [];
348-
if (iam_policies.length === 0) return;
346+
if (iam_policies.length === 0 && req.object_sdk.nsfs_config_root) return; // We do not have IAM policies in NC yet
349347

350348
// parallel policy check
351349
const promises = [];

0 commit comments

Comments
 (0)