-
Notifications
You must be signed in to change notification settings - Fork 331
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
api: add get_bucket_policy and set_bucket_policy. #385
Conversation
what else is needed here @balamurugana ? |
Checking again what else is pending here to get this merged @balamurugana ? |
Fixed in the latest refresh. |
Fixed in latest refresh. |
Below policy JSON is set. mc.set_bucket_policy(Policy.READ_ONLY, "mybucket", "hello") {"Statement": [{"Action": "s3:GetBucketLocation",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:ListBucket",
"Condition": {"StringEquals": {"s3:prefix": "hello"}},
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:GetObject",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/hello*",
"Sid": ""}],
"Version": "2012-10-17"} mc.set_bucket_policy(Policy.READ_WRITE, "mybucket", "world") {"Statement": [{"Action": "s3:GetBucketLocation",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:GetObject",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/hello*",
"Sid": ""},
{"Action": "s3:ListBucket",
"Condition": {"StringEquals": {"s3:prefix": ["world", "hello"]}},
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:ListBucketMultipartUploads",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": ["s3:ListMultipartUploadParts",
"s3:GetObject",
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:PutObject"],
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/world*",
"Sid": ""}],
"Version": "2012-10-17"} mc.set_bucket_policy(Policy.READ_WRITE, "mybucket") {"Statement": [{"Action": "s3:GetBucketLocation",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:GetObject",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/hello*",
"Sid": ""},
{"Action": "s3:ListBucketMultipartUploads",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": ["s3:ListMultipartUploadParts",
"s3:GetObject",
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:PutObject"],
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/world*",
"Sid": ""},
{"Action": "s3:ListBucket",
"Condition": {"StringEquals": {"s3:prefix": ["world", "hello"]}},
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": "s3:ListBucket",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket",
"Sid": ""},
{"Action": ["s3:ListMultipartUploadParts",
"s3:GetObject",
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:PutObject"],
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Resource": "arn:aws:s3:::mybucket/*",
"Sid": ""}],
"Version": "2012-10-17"} |
|
||
policy_dict = self._get_bucket_policy(bucket_name) | ||
if policy_access == policy.Policy.NONE and not policy_dict: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to return an error here..We raise an exception. NoSuchBucketPolicy
@balamurugana can you add examples, update README.md and API.md as well. |
Done in latest refresh. |
Fixes ##377