Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/cldsrv 427 permissions check #5421

Closed

Conversation

benzekrimaha
Copy link
Contributor

PR opened after closing : #5323

Bucket policies are not correctly interpreted, this is part of the following epic to fix that: scality/Arsenal#2181

This PR is aiming enable authorization logics from IAM policies, bucket policies and ACLs to be interpreted in aggregate in CloudServer's 'isBucketAuthorized' and 'isObjectAuthorized' functions. , ticket linked to this issue here : https://scality.atlassian.net/browse/CLDSRV-427

PRs providing implicit Deny logic to CS for processing in this PR
scality/Arsenal#2181
https://github.com/scality/Vault/pull/2135
#5322
#5420

I'm not bumping a new CLDSRV version since a new version has been created in this merged PR : #5322 , Please let me know if it needs to be done anyways.

@bert-e
Copy link
Contributor

bert-e commented Nov 7, 2023

Hello benzekrimaha,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Nov 7, 2023

Incorrect fix version

The Fix Version/s in issue CLDSRV-427 contains:

  • 7.70.30

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 7.10.33

  • 7.70.30

  • 8.6.12

  • 8.7.31

  • 8.8.5

Please check the Fix Version/s of CLDSRV-427, or the target
branch of this pull request.

Copy link

@KazToozs KazToozs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code makes sense otherwise

return false;
}
return (aclPermission || (bucketPolicyPermission === 'allow'));
if (method === 'isBucketAuthorized') {
Copy link

@KazToozs KazToozs Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm of the personal opinion that if such conditions are necessary for such large parts of code, it's better practice to keep this separate into smaller, different functions.

Copy link
Contributor Author

@benzekrimaha benzekrimaha Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this check was only added for the bucket specific checks/ object ones in the else , as the functions are nearly identical besides for those checks I used the method param passed by the functions 'isBucketAUthorized', 'isObjectAuthorized' and 'evaluateBucketPolicyWithIAM' to separate them and keep all of the changes related to authorizations in only one function (can ease modifications in the future as well)

Comment on lines 287 to 352
requestTypes.forEach(requestType => {
if (actionImplicitDenies[requestType] === undefined) {
// eslint-disable-next-line no-param-reassign
actionImplicitDenies[requestType] = false;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to initialize undefined values of actionImplicitDenies.
Inside the second forEach you can directly test if it's false with !!actionImplicitDenies[requestType].

return true;
const results = {};
const mainApiCall = requestTypes[0];
requestTypes.forEach(_requestType => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly return requestTypes.every(_requestType => {...}) instead of storing and checking all the results.
This will also avoid looping over everything when you encounter a first error.

lib/api/apiUtils/authorization/permissionChecks.js Outdated Show resolved Hide resolved
@benzekrimaha benzekrimaha changed the base branch from development/7.10 to improvement/CLDSRV-426-acl-impl-deny November 10, 2023 10:21
Will Toozs and others added 8 commits November 10, 2023 11:36
change variable names for clarity

edit: update arsenal package
Update lib/api/api.js

Co-authored-by: Jonathan Gramain <[email protected]>
CLDSRV-426:fixups on ACL permission checks for implicitDeny logic

CLDSRV-426:better readability on ACL permission
@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-427-permissions-check branch from bb3da5a to e572f97 Compare November 10, 2023 10:36
@benzekrimaha benzekrimaha changed the base branch from improvement/CLDSRV-426-acl-impl-deny to development/7.10 November 10, 2023 10:38
@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-427-permissions-check branch from e572f97 to 6919ca7 Compare November 10, 2023 10:53
- In this commit , I added a helper (processBucketPolicy) function
for the bycket policies checks that are shared between the
isbucketAuthorized, isObjAuthorized and evaluateBucketPolicyWithIAM
for a better code readability and to avoid long functions.
@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-427-permissions-check branch from 15ef59c to 33d7c99 Compare November 10, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants