Skip to content

Conversation

@ebozduman
Copy link
Collaborator

Fixes #635

docs/API.md Outdated
]}


minioClient.set_bucket_policy('mybucket', policy_READ_ONLY)
Copy link
Contributor

Choose a reason for hiding this comment

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

would be better to rename this variable as policy_read_only

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

# enables 'my-bucketname' readable by everyone.
client.set_bucket_policy('my-bucketname', '', Policy.READ_ONLY)
# Set bucket policy to read-only for bucket 'my-bucketname'
policy_READ_ONLY = {
Copy link
Contributor

Choose a reason for hiding this comment

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

lower casing this variable is better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

client.set_bucket_policy('my-bucketname', 'public-folder/',
Policy.READ_WRITE)
# Set bucket policy to read-write for bucket 'my-bucketname'
policy_READ_WRITE = {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/policy_READ_WRITE/policy_read_write

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

# writeable by everyone.
client.set_bucket_policy('my-bucketname', 'incoming',
Policy.WRITE_ONLY)
# Set bucket policy to write-only for bucket 'my-bucketname'
Copy link
Contributor

Choose a reason for hiding this comment

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

s/policy_WRITE_ONLY/policy_write_only

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

policy_name = client.get_bucket_policy(bucket_name)
if policy_name != Policy.READ_ONLY:
raise ValueError('Failed to set ReadOnly bucket policy: ' + policy_name)
if not policy_validated(client, bucket_name, policy):
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't a simple string compare of policy json to be uploaded and policy retrieved by get_bucket_policy validate this? Don't see a need for this helper function.

Copy link
Collaborator Author

@ebozduman ebozduman Mar 30, 2018

Choose a reason for hiding this comment

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

I've seen different, sometimes duplicate Action and/or Resource entries returned from the server. So, the format of the json response is not guaranteed to be the same each time. That's why I've introduced the helper function.

policy = minioClient.get_bucket_policy('mybucket',
'my-prefixname')
# Get current policy of all object paths in bucket "mybucket".
policy = minioClient.get_bucket_policy('mybucket')
Copy link
Member

Choose a reason for hiding this comment

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

When the bucket doesn't have a policy, this function raises minio.error.NoSuchBucketPolicy exception, before, we were returning None. It makes sense to discuss if we need to keep the old behavior or not, and document this in all cases.

Copy link
Member

Choose a reason for hiding this comment

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

We should return NoSuchBucketPolicy since that would be expected now. it's a breaking change so don't expect old behavior.

Copy link
Member

Choose a reason for hiding this comment

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

okay, then we need to document this

Copy link
Collaborator Author

@ebozduman ebozduman Mar 30, 2018

Choose a reason for hiding this comment

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

You mean in the Release Notes, right? Yes, we have to explain this breaking change in the Release Notes.

Copy link
Member

Choose a reason for hiding this comment

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

We should simply bump the major version, it is expected that they revisit their applications after such an upgrade.

@ebozduman
Copy link
Collaborator Author

@vadmeste, @harshavardhana, @poornas ,
Could you re-review it? Thanks.

@poornas
Copy link
Contributor

poornas commented Apr 3, 2018

@ebozduman, please check the build failures.

poornas
poornas previously requested changes Apr 3, 2018
docs/API.md Outdated
minioClient.set_bucket_policy('mybucket',
'my-prefixname',
Policy.READ_ONLY)
# Set policy to read only to all object paths in bucket.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest rewording line 361 to Set bucket policy to read only

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.
Also resolved Travis problem.

@ebozduman ebozduman force-pushed the policy_rewrite2 branch 3 times, most recently from 55574fa to 3be945f Compare April 4, 2018 16:24
@ebozduman
Copy link
Collaborator Author

@poornas, @harshavardhana, @krishnasrinivas,
Could you review it again?
Thanks.

@ebozduman
Copy link
Collaborator Author

@poornas, @harshavardhana, @krishnasrinivas,
Ping! for review...

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM & tested

poornas
poornas previously approved these changes Apr 19, 2018
Copy link
Contributor

@poornas poornas left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

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

One thing missing is version needs to be updated @ebozduman

@nitisht nitisht merged commit fcd728f into minio:master Apr 20, 2018
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.

5 participants