-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Storage: add 'bucket_policy_only' IAM property #7066
Storage: add 'bucket_policy_only' IAM property #7066
Conversation
@frankyn I've added system tests exercising the feature. PTAL. |
storage/tests/system.py
Outdated
with self.assertRaises(exceptions.BadRequest): | ||
bucket.acl.reload() | ||
|
||
# XXX This should raise, but doesn't as of 2018-01-08T19:00:00Z |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -272,6 +272,82 @@ def from_api_repr(cls, resource): | |||
return instance | |||
|
|||
|
|||
class IAMConfiguration(dict): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
storage/tests/system.py
Outdated
#with self.assertRaises(exceptions.BadRequest): | ||
# bucket.acl.clear() | ||
|
||
# XXX The blob ACL get / set stuff raises 403, rather than 400. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Manages conversion of a bucket's IAM configuration to / from the JSON repr.
Note oddities in the second and third, perhaps due to rollout issues.
This reverts commit 6814a4f.
@frankyn PTAL. |
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.
two requests on related documentation. Thanks @tseaver overall LGTM. Please don't merge until given the OK.
"""When was the bucket configured to allow only IAM policy? | ||
|
||
:rtype: Union[:class:`datetime.datetime`, None] | ||
:returns: (readonly) the time the bucket's IAM-only policy was set. |
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.
Use discovery document description for lockedTime:
The deadline time for changing iamConfiguration.bucketPolicyOnly.enabled from true to false in RFC 3339 format. iamConfiguration.bucketPolicyOnly.enabled may be changed from true to false until the locked time, after which the field is immutable.
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.
|
||
@property | ||
def bucket_policy_only(self): | ||
"""Is the bucket configured to allow only IAM policy? |
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.
From discovery document. "If set, access checks only use bucket-level IAM policies or above."
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.
@frankyn Please remove the 'do not merge' label when the back-end is ready for me to merge this PR. |
Acking, thank you @tseaver! |
self.bucket._patch_property("iamConfiguration", self) | ||
|
||
@property | ||
def locked_time(self): |
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.
Hi @tseaver, I just realized this isn't scoped according to BucketPolicyOnly
only. Could you move this to be at the same context of bucket_policy_only?
I'm writing samples and I missed this during review. I'm thinking it should have the following pattern.
iam_configuration.bucket_policy_only_enabled
iam_configuration.bucket_policy_only_locked_time
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.
Thanks @tseaver LGTM. I'll remove the label when it's time to release. |
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.
The whitelist is no longer required. LGTM'ing.
@frankyn Still working on system tests. I can test creating a new bucket with BPO enabled, but am unable to update a newly-created non-BPO bucket to have BPO set: the
PATCH
request returns: