-
Notifications
You must be signed in to change notification settings - Fork 89
IAM | put_bucket_policy Principal validation updated with ARN #9277
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
naveenpaul1 marked this conversation as resolved.
Show resolved
Hide resolved
|
shirady marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ const addr_utils = require('../../util/addr_utils'); | |||||||||||||||||||
| const kube_utils = require('../../util/kube_utils'); | ||||||||||||||||||||
| const jwt_utils = require('../../util/jwt_utils'); | ||||||||||||||||||||
| const config = require('../../../config'); | ||||||||||||||||||||
| const iam_utils = require('../../endpoint/iam/iam_utils'); | ||||||||||||||||||||
| const s3_bucket_policy_utils = require('../../endpoint/s3/s3_bucket_policy_utils'); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -548,10 +549,11 @@ async function has_bucket_action_permission(bucket, account, action, req_query, | |||||||||||||||||||
| if (!action) { | ||||||||||||||||||||
| throw new Error('has_bucket_action_permission: action is required'); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const arn = account.owner ? iam_utils.create_arn_for_user(account.owner._id.toString(), account.name.unwrap().split(':')[0], account.iam_path) : | ||||||||||||||||||||
| iam_utils.create_arn_for_root(account._id); | ||||||||||||||||||||
| const result = await s3_bucket_policy_utils.has_bucket_policy_permission( | ||||||||||||||||||||
|
Comment on lines
+552
to
554
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle string and object owners when building ARN In S3 REST flows the requesting account arrives over RPC with - const arn = account.owner ? iam_utils.create_arn_for_user(account.owner._id.toString(), account.name.unwrap().split(':')[0], account.iam_path) :
- iam_utils.create_arn_for_root(account._id);
+ const owner_id = typeof account.owner === 'object' ? account.owner._id : account.owner;
+ const iam_user_name = account.name.unwrap().split(':')[0];
+ const arn = owner_id ?
+ iam_utils.create_arn_for_user(owner_id.toString(), iam_user_name, account.iam_path) :
+ iam_utils.create_arn_for_root(account._id);Based on learnings 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| bucket_policy, | ||||||||||||||||||||
| account.email.unwrap(), | ||||||||||||||||||||
| arn, | ||||||||||||||||||||
| action, | ||||||||||||||||||||
| `arn:aws:s3:::${bucket.name.unwrap()}${bucket_path}`, | ||||||||||||||||||||
| req_query | ||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.