Skip to content

Commit 5fef7ca

Browse files
committed
CI FIx
1 parent 7137dbf commit 5fef7ca

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/sdk/accountspace_nb.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AccountSpaceNB {
5050
//const root_account = _.find(system_store.data.accounts, account => account.name.unwrap() === requesting_account.name.unwrap());
5151
const requesting_account = system_store.get_account_by_email(account_sdk.requesting_account.email);
5252
account_util._check_if_requesting_account_is_root_account(action, requesting_account,
53-
{ username: params.username, iam_path: params.iam_path });
53+
{ username: params.username, path: params.iam_path });
5454
account_util._check_username_already_exists(action, params, requesting_account);
5555
const iam_arn = iam_utils.create_arn_for_user(requesting_account._id.toString(), params.username, params.iam_path);
5656
const account_name = new SensitiveString(`${params.username}:${requesting_account.name.unwrap()}`);
@@ -64,7 +64,9 @@ class AccountSpaceNB {
6464
owner: requesting_account._id.toString(),
6565
is_iam: true,
6666
iam_arn: iam_arn,
67+
iam_path: params.iam_path,
6768
role: 'iam_user',
69+
6870
// TODO: default_resource remove
6971
default_resource: 'noobaa-default-backing-store',
7072
},
@@ -82,7 +84,7 @@ class AccountSpaceNB {
8284
username: params.username,
8385
user_id: iam_account.id,
8486
arn: iam_arn,
85-
create_date: iam_account.creation_date,
87+
create_date: iam_account.create_date,
8688
};
8789

8890
}
@@ -106,8 +108,8 @@ class AccountSpaceNB {
106108
iam_path: requested_account.iam_path || IAM_DEFAULT_PATH,
107109
username: requested_account.name.unwrap().split(IAM_SPLIT_CHARACTERS)[0],
108110
arn: requested_account.iam_arn,
111+
create_date: new Date(requested_account.last_update),
109112
// TODO: Dates missing : GAP
110-
create_date: new Date(),
111113
password_last_used: new Date(),
112114
};
113115
return reply;
@@ -123,6 +125,7 @@ class AccountSpaceNB {
123125
const requested_account = system_store.get_account_by_email(account_name);
124126
let new_iam_path = requested_account.iam_path;
125127
let new_user_name = requested_account.name.unwrap();
128+
account_util._check_username_already_exists(action, { username: params.new_username }, requesting_account);
126129
const root_account = _.find(system_store.data.accounts, account => account.name.unwrap() === requesting_account.name.unwrap());
127130
account_util._check_if_requested_account_is_root_account_or_IAM_user(action, requesting_account, requested_account);
128131
account_util._check_if_requested_is_owned_by_root_account(action, root_account, requested_account);
@@ -136,7 +139,7 @@ class AccountSpaceNB {
136139
iam_arn: iam_arn,
137140
};
138141
// CORE CHANGES PENDING - START
139-
system_store.make_changes({
142+
await system_store.make_changes({
140143
update: {
141144
accounts: [{
142145
_id: requested_account._id,
@@ -149,8 +152,8 @@ class AccountSpaceNB {
149152
// TODO : Send Event
150153
return {
151154
// TODO: IAM path needs to be saved
152-
iam_path: requested_account.iam_path || IAM_DEFAULT_PATH,
153-
username: requested_account.name.unwrap(),
155+
iam_path: new_iam_path || IAM_DEFAULT_PATH,
156+
username: new_user_name,
154157
user_id: requested_account._id.toString(),
155158
arn: iam_arn
156159
};
@@ -203,7 +206,8 @@ class AccountSpaceNB {
203206
iam_path: iam_user.iam_path || IAM_DEFAULT_PATH,
204207
username: iam_user.name.unwrap().split(IAM_SPLIT_CHARACTERS)[0],
205208
arn: iam_user.iam_arn,
206-
create_date: iam_user.creation_date,
209+
create_date: new Date(iam_user.last_update),
210+
// TODO: Miising password_last_used
207211
password_last_used: Date.now(), // GAP
208212
};
209213
return member;

src/server/system_services/account_server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const check_new_azure_connection_timeout = 20 * 1000;
3535
*/
3636
async function create_account(req) {
3737

38+
3839
account_util.validate_create_account_permissions(req);
3940
account_util.validate_create_account_params(req);
4041
const {token, access_keys} = await account_util.create_account(req);

src/server/system_services/schemas/account_schema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ module.exports = {
2828
password: { wrapper: SensitiveString }, // bcrypted password - DEPRECATED
2929
next_password_change: { date: true }, // DEPRECATED
3030
// TODO: Check NSFS behaviour for account and iam user
31-
owner: { type: 'string' },
31+
owner: { objectid: true },
3232
tagging: {
3333
$ref: 'common_api#/definitions/tagging',
3434
},
3535
is_iam: { type: 'boolean' },
3636
iam_arn: { type: 'string' },
37+
iam_path: { type: 'string' },
3738
// default policy for new buckets
3839
default_resource: { objectid: true },
3940
default_chunk_config: { objectid: true },

src/util/account_util.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { OP_NAME_TO_ACTION } = require('../endpoint/sts/sts_rest');
1515
const IamError = require('../endpoint/iam/iam_errors').IamError;
1616
//const { account_cache } = require('./../sdk/object_sdk');
1717
const { create_arn_for_user, get_action_message_title } = require('../endpoint/iam/iam_utils');
18-
const { IAM_ACTIONS, ACCESS_KEY_STATUS_ENUM } = require('../endpoint/iam/iam_constants');
18+
const { IAM_ACTIONS, IAM_DEFAULT_PATH } = require('../endpoint/iam/iam_constants');
1919

2020
const demo_access_keys = Object.freeze({
2121
access_key: new SensitiveString('123'),
@@ -115,6 +115,7 @@ async function create_account(req) {
115115
account.owner = req.rpc_params.owner;
116116
account.is_iam = req.rpc_params.is_iam;
117117
account.iam_arn = req.rpc_params.iam_arn;
118+
account.iam_path = req.rpc_params.iam_path;
118119
}
119120

120121
await system_store.make_changes({
@@ -216,7 +217,6 @@ async function generate_account_keys(req) {
216217
const decrypted_access_keys = _.cloneDeep(access_keys);
217218
access_keys.secret_key = system_store.master_key_manager.encrypt_sensitive_string_with_master_key_id(
218219
access_keys.secret_key, account.master_key_id._id);
219-
access_keys.deactivated = false;
220220

221221
await system_store.make_changes({
222222
update: {
@@ -415,7 +415,7 @@ function _throw_access_denied_error(action, requesting_account, details, entity)
415415
const full_action_name = get_action_message_title(action);
416416
const account_id_for_arn = _get_account_owner_id_for_arn(requesting_account);
417417
const arn_for_requesting_account = create_arn_for_user(account_id_for_arn,
418-
requesting_account.name.unwrap(), requesting_account.path);
418+
requesting_account.name.unwrap(), requesting_account.path || IAM_DEFAULT_PATH);
419419
const basic_message = `User: ${arn_for_requesting_account} is not authorized to perform:` +
420420
`${full_action_name} on resource: `;
421421
let message_with_details;
@@ -459,9 +459,6 @@ function _check_root_account(account) {
459459
return account.owner === undefined;
460460
}
461461

462-
function _check_access_key_is_deactivated(status) {
463-
return status === ACCESS_KEY_STATUS_ENUM.INACTIVE;
464-
}
465462

466463

467464
function validate_create_account_permissions(req) {
@@ -550,6 +547,5 @@ exports.validate_create_account_permissions = validate_create_account_permission
550547
exports.validate_create_account_params = validate_create_account_params;
551548
exports._check_if_account_exists = _check_if_account_exists;
552549
exports._returned_username = _returned_username;
553-
exports._check_access_key_is_deactivated = _check_access_key_is_deactivated;
554550
exports._check_if_requested_is_owned_by_root_account = _check_if_requested_is_owned_by_root_account;
555551
exports._check_if_requested_account_is_root_account_or_IAM_user = _check_if_requested_account_is_root_account_or_IAM_user;

0 commit comments

Comments
 (0)