CLDSRV-674: handle cross-account bucket policies#5855
CLDSRV-674: handle cross-account bucket policies#5855bert-e merged 4 commits intodevelopment/7.70from
Conversation
Hello leif-scality,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
This comment was marked as outdated.
This comment was marked as outdated.
ccf75c1 to
b4639ec
Compare
b4639ec to
15d4bab
Compare
Request integration branchesWaiting for integration branch creation to be requested by the user. To request integration branches, please comment on this pull request with the following command: Alternatively, the |
15d4bab to
1d88478
Compare
| for (const p of principal.CanonicalUser) { | ||
| if (out === checkPrincipalResult.OK) { | ||
| break; | ||
| } | ||
|
|
||
| const res = _checkPrincipal(canonicalID, p, bucketOwnerCanonicalID, canonicalID); | ||
| if (res !== checkPrincipalResult.KO) { | ||
| out = res; | ||
| } | ||
| } | ||
| return out; |
There was a problem hiding this comment.
to avoid nested if/for and duplication we should be able to use a helper function
something like:
function _findBestPrincipalMatch(principalArray, checkFunc) {
let bestMatch = checkPrincipalResult.KO;
if (!principalArray) {
return bestMatch;
}
const principals = Array.isArray(principalArray) ? principalArray : [principalArray];
for (const p of principals) {
const result = checkFunc(p);
if (result === checkPrincipalResult.OK) {
return checkPrincipalResult.OK; // Highest permission, can exit early
}
if (result > bestMatch) {
bestMatch = result;
}
}
return bestMatch;
}
function _checkPrincipals(canonicalID, arn, principal, bucketOwnerCanonicalID) {
if (principal === '*') {
// Handle anonymous or authenticated wildcard
if (arn === undefined) {
return checkPrincipalResult.OK;
}
return _getPermissionLevel(arn, bucketOwnerCanonicalID, canonicalID); // Assuming _getPermissionLevel is refactored
}
if (principal.CanonicalUser) {
return _findBestPrincipalMatch(principal.CanonicalUser, p =>
_checkPrincipal(canonicalID, p, bucketOwnerCanonicalID, canonicalID));
}
if (principal.AWS) {
return _findBestPrincipalMatch(principal.AWS, p =>
_checkPrincipal(arn, p, bucketOwnerCanonicalID, canonicalID));
}
return checkPrincipalResult.KO;
}1d88478 to
d4a82f0
Compare
|
@williamlardier I kept the diagram because the one in citadel is higher level than this one, I also think the diagram makes the function easier to understand. |
| return _checkCrossAccount(requesterARN, requesterCanonicalID, bucketOwnerCanonicalID); | ||
| } | ||
|
|
||
| if (principal.endsWith('root') && _getAccountId(principal) === _getAccountId(requesterARN)) { |
There was a problem hiding this comment.
Shouldn't it be /root to avoid valid user names ending in root?
| if (principal.endsWith('root') && _getAccountId(principal) === _getAccountId(requesterARN)) { | |
| if (principal.endsWith('/root') && _getAccountId(principal) === _getAccountId(requesterARN)) { |
maybe a more formal check here would be better
There was a problem hiding this comment.
I think we should do :root, /root is not a valid ARN, /account_name is only returned by vault when using the root access key's as explained in _IsRoot.
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-accounts
f97e991 to
969e154
Compare
|
ping |
|
@bert-e create_pull_requests |
Integration data createdI have created the integration data for the additional destination branches.
The following branches will NOT be impacted:
Follow integration pull requests if you would like to be notified of The following options are set: create_pull_requests, create_integration_branches |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
The following options are set: create_pull_requests, create_integration_branches |
|
/approve |
Build failedThe build for commit did not succeed in branch w/8.8/bugfix/CLDSRV-674 The following options are set: approve, create_pull_requests, create_integration_branches |
Build failedThe build for commit did not succeed in branch w/9.0/bugfix/CLDSRV-674 The following options are set: approve, create_pull_requests, create_integration_branches |
Build failedThe build for commit did not succeed in branch w/9.1/bugfix/CLDSRV-674 The following options are set: approve, create_pull_requests, create_integration_branches |
Build failedThe build for commit did not succeed in branch w/9.0/bugfix/CLDSRV-674 The following options are set: approve, create_pull_requests, create_integration_branches |
Build failedThe build for commit did not succeed in branch w/9.1/bugfix/CLDSRV-674 The following options are set: approve, create_pull_requests, create_integration_branches |
|
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
Please check the status of the associated issue CLDSRV-674. Goodbye leif-scality. The following options are set: approve, create_pull_requests, create_integration_branches |
Handle cross account cases when using bucket policies
https://scality.atlassian.net/browse/S3C-9896