Skip to content

Commit 1187986

Browse files
Merge pull request #9038 from romayalon/romy-5.18-backports
IAM backports to 5.18.4
2 parents c8e8bd1 + ea4c49b commit 1187986

14 files changed

+165
-16
lines changed

docs/design/iam.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ Here attached a diagram with all the accounts that we have in our system:
127127
- IAM DeleteAccessKey: AccessKeyId, UserName
128128
- IAM ListAccessKeys: UserName (not supported: Marker, MaxItems)
129129

130+
### Other
131+
- IAM ListGroupsForUser - would always return empty list (to check that the user exists it runs GetUser).
132+
130133
### Configuration Directory Components With users
131134
If account creates a user its config file will be created under identities/<user-id>.identity.json and under the account will be created `users/` directory and inside it it will link to the config.
132135
Example:

src/endpoint/iam/iam_rest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ACTIONS = Object.freeze({
3434
'UpdateAccessKey': 'update_access_key',
3535
'DeleteAccessKey': 'delete_access_key',
3636
'ListAccessKeys': 'list_access_keys',
37+
'ListGroupsForUser': 'list_groups_for_user',
3738
});
3839

3940
// notice: shows all methods as method post
@@ -50,6 +51,8 @@ const IAM_OPS = js_utils.deep_freeze({
5051
post_update_access_key: require('./ops/iam_update_access_key'),
5152
post_delete_access_key: require('./ops/iam_delete_access_key'),
5253
post_list_access_keys: require('./ops/iam_list_access_keys'),
54+
// other (currently ops that return empty just not to fail them)
55+
post_list_groups_for_user: require('./ops/iam_list_groups_for_user.js'),
5356
});
5457

5558
async function iam_rest(req, res) {
@@ -145,6 +148,7 @@ function parse_op_name(req, action) {
145148
if (ACTIONS[action]) {
146149
return `${method}_${ACTIONS[action]}`;
147150
}
151+
dbg.error('IAM parse_op_name - NotImplemented', action, method, req.originalUrl);
148152
throw new IamError(IamError.NotImplemented);
149153
}
150154

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Copyright (C) 2024 NooBaa */
2+
'use strict';
3+
4+
const dbg = require('../../../util/debug_module')(__filename);
5+
const { CONTENT_TYPE_APP_FORM_URLENCODED } = require('../../../util/http_utils');
6+
const iam_utils = require('../iam_utils');
7+
const iam_constants = require('../iam_constants');
8+
9+
/**
10+
* https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListGroupsForUser.html
11+
*/
12+
async function list_groups_for_user(req, res) {
13+
14+
const params = {
15+
username: req.body.user_name,
16+
};
17+
18+
dbg.log1('To check that we have the user we will run the IAM GET USER', params);
19+
iam_utils.validate_params(iam_constants.IAM_ACTIONS.GET_USER, params);
20+
await req.account_sdk.get_user(params);
21+
22+
dbg.log1('IAM LIST GROUPS FOR USER (returns empty list on every request)', params);
23+
24+
return {
25+
ListGroupsForUserResponse: {
26+
ListGroupsForUserResult: {
27+
Groups: [],
28+
IsTruncated: false,
29+
},
30+
ResponseMetadata: {
31+
RequestId: req.request_id,
32+
}
33+
},
34+
};
35+
}
36+
37+
module.exports = {
38+
handler: list_groups_for_user,
39+
body: {
40+
type: CONTENT_TYPE_APP_FORM_URLENCODED,
41+
},
42+
reply: {
43+
type: 'xml',
44+
},
45+
};

src/endpoint/s3/ops/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exports.get_bucket_object_lock = require('./s3_get_bucket_object_lock');
3131
exports.get_bucket_policy = require('./s3_get_bucket_policy');
3232
exports.get_bucket_policy_status = require('./s3_get_bucket_policy_status');
3333
exports.get_bucket_replication = require('./s3_get_bucket_replication');
34-
exports.get_bucket_requestPayment = require('./s3_get_bucket_requestPayment');
34+
exports.get_bucket_request_payment = require('./s3_get_bucket_request_payment');
3535
exports.get_bucket_tagging = require('./s3_get_bucket_tagging');
3636
exports.get_bucket_uploads = require('./s3_get_bucket_uploads');
3737
exports.get_bucket_versioning = require('./s3_get_bucket_versioning');
@@ -67,7 +67,7 @@ exports.put_bucket_notification = require('./s3_put_bucket_notification');
6767
exports.put_bucket_object_lock = require('./s3_put_bucket_object_lock');
6868
exports.put_bucket_policy = require('./s3_put_bucket_policy');
6969
exports.put_bucket_replication = require('./s3_put_bucket_replication');
70-
exports.put_bucket_requestPayment = require('./s3_put_bucket_requestPayment');
70+
exports.put_bucket_request_payment = require('./s3_put_bucket_request_payment');
7171
exports.put_bucket_tagging = require('./s3_put_bucket_tagging');
7272
exports.put_bucket_versioning = require('./s3_put_bucket_versioning');
7373
exports.put_bucket_website = require('./s3_put_bucket_website');

src/endpoint/s3/ops/s3_get_bucket_requestPayment.js renamed to src/endpoint/s3/ops/s3_get_bucket_request_payment.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
/* Copyright (C) 2016 NooBaa */
22
'use strict';
33

4+
const dbg = require('../../../util/debug_module')(__filename);
5+
46
/**
57
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentGET.html
68
*/
7-
async function get_bucket_requestPayment(req) {
9+
async function get_bucket_request_payment(req) {
810
await req.object_sdk.read_bucket({ name: req.params.bucket });
11+
const payer = 'BucketOwner';
12+
dbg.log1(`s3_get_bucket_request_payment (returns ${payer} on every request)`);
913
return {
1014
RequestPaymentConfiguration: {
11-
Payer: 'BucketOwner'
15+
Payer: payer
1216
}
1317
};
1418
}
1519

1620
module.exports = {
17-
handler: get_bucket_requestPayment,
21+
handler: get_bucket_request_payment,
1822
body: {
1923
type: 'empty',
2024
},

src/endpoint/s3/ops/s3_put_bucket_requestPayment.js renamed to src/endpoint/s3/ops/s3_put_bucket_request_payment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ const S3Error = require('../s3_errors').S3Error;
66
/**
77
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentPUT.html
88
*/
9-
async function put_bucket_requestPayment(req) {
9+
async function put_bucket_request_payment(req) {
1010
await req.object_sdk.read_bucket({ name: req.params.bucket });
1111
// TODO S3 put_bucket_requestPayment not implemented
1212
throw new S3Error(S3Error.NotImplemented);
1313
}
1414

1515
module.exports = {
16-
handler: put_bucket_requestPayment,
16+
handler: put_bucket_request_payment,
1717
body: {
1818
type: 'xml',
1919
},

src/endpoint/s3/s3_bucket_policy_utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const OP_NAME_TO_ACTION = Object.freeze({
3636
get_bucket_policy: { regular: "s3:GetBucketPolicy" },
3737
get_bucket_policy_status: { regular: "s3:GetBucketPolicyStatus" },
3838
get_bucket_replication: { regular: "s3:GetReplicationConfiguration" },
39-
get_bucket_requestpayment: { regular: "s3:GetBucketRequestPayment" },
39+
get_bucket_request_payment: { regular: "s3:GetBucketRequestPayment" },
4040
get_bucket_tagging: { regular: "s3:GetBucketTagging" },
4141
get_bucket_uploads: { regular: "s3:ListBucketMultipartUploads" },
4242
get_bucket_versioning: { regular: "s3:GetBucketVersioning" },
@@ -75,7 +75,7 @@ const OP_NAME_TO_ACTION = Object.freeze({
7575
put_bucket_notification: { regular: "s3:PutBucketNotification" },
7676
put_bucket_policy: { regular: "s3:PutBucketPolicy" },
7777
put_bucket_replication: { regular: "s3:PutReplicationConfiguration" },
78-
put_bucket_requestpayment: { regular: "s3:PutBucketRequestPayment" },
78+
put_bucket_request_payment: { regular: "s3:PutBucketRequestPayment" },
7979
put_bucket_tagging: { regular: "s3:PutBucketTagging" },
8080
put_bucket_versioning: { regular: "s3:PutBucketVersioning" },
8181
put_bucket_website: { regular: "s3:PutBucketWebsite" },

src/endpoint/s3/s3_rest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const BUCKET_SUB_RESOURCES = Object.freeze({
3636
'policy': 'policy',
3737
'policyStatus': 'policy_status',
3838
'replication': 'replication',
39-
'requestPayment': 'requestPayment',
39+
'requestPayment': 'request_payment',
4040
'tagging': 'tagging',
4141
'uploads': 'uploads',
4242
'versioning': 'versioning',

src/endpoint/sts/sts_rest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function parse_op_name(req, action) {
163163
if (ACTIONS[action]) {
164164
return `${method}_${ACTIONS[action]}`;
165165
}
166+
dbg.error('STS parse_op_name - NotImplemented', action, method, req.originalUrl);
166167
throw new StsError(StsError.NotImplemented);
167168
}
168169

src/sdk/bucketspace_fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class BucketSpaceFS extends BucketSpaceSimpleFS {
683683
const { name } = params;
684684
dbg.log0('BucketSpaceFS.get_bucket_encryption: Bucket name', name);
685685
const bucket = await this.config_fs.get_bucket_by_name(name);
686-
return bucket.encryption;
686+
return { encryption: bucket.encryption };
687687
} catch (err) {
688688
throw translate_error_codes(err, entity_enum.BUCKET);
689689
}

0 commit comments

Comments
 (0)