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

feat: (storage) support for uniform bucket-level access #2146

Merged
merged 6 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Storage/src/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,16 @@ public function delete(array $options = [])
* that objects need to be retained, in seconds. Retention
* duration must be greater than zero and less than 100 years.
* @type array $iamConfiguration The bucket's IAM configuration.
* @type bool $iamConfiguration.bucketPolicyOnly.enabled If set and
* @type bool $iamConfiguration.bucketPolicyOnly.enabled this is an alias
* for $iamConfiguration.uniformBucketLevelAccess.
* @type bool $iamConfiguration.uniformBucketLevelAccess.enabled If set and
* true, access checks only use bucket-level IAM policies or
* above. When enabled, requests attempting to view or manipulate
* ACLs will fail with error code 400. **NOTE**: Before using
* Bucket Policy Only, please review the
* [feature documentation](https://cloud.google.com/storage/docs/bucket-policy-only),
* Uniform bucket-level access, please review the
* [feature documentation](https://cloud.google.com/storage/docs/uniform-bucket-level-access),
* as well as
* [Should You Use Bucket Policy Only](https://cloud.google.com/storage/docs/bucket-policy-only#should-you-use)
* [Should You Use uniform bucket-level access](https://cloud.google.com/storage/docs/uniform-bucket-level-access#should-you-use)
* }
* @codingStandardsIgnoreEnd
* @return array
Expand Down
10 changes: 6 additions & 4 deletions Storage/src/StorageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@ function (array $bucket) use ($userProject) {
* object cannot be overwritten or deleted. Retention period must
* be greater than zero and less than 100 years.
* @type array $iamConfiguration The bucket's IAM configuration.
* @type bool $iamConfiguration.bucketPolicyOnly.enabled If set and
* @type bool $iamConfiguration.bucketPolicyOnly.enabled this is an alias
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just remove bucketPolicyOnly? It'll continue to work for people already using it, and for people reading the docs for the first time it's less unhelpful information.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the mean time I think we should keep it. @JesseLovelace in case they have additional input.

* for $iamConfiguration.uniformBucketLevelAccess.
* @type bool $iamConfiguration.uniformBucketLevelAccess.enabled If set and
* true, access checks only use bucket-level IAM policies or
* above. When enabled, requests attempting to view or manipulate
* ACLs will fail with error code 400. **NOTE**: Before using
* Bucket Policy Only, please review the
* [feature documentation](https://cloud.google.com/storage/docs/bucket-policy-only),
* Uniform bucket-level access, please review the
* [feature documentation](https://cloud.google.com/storage/docs/uniform-bucket-level-access),
* as well as
* [Should You Use Bucket Policy Only](https://cloud.google.com/storage/docs/bucket-policy-only#should-you-use)
* [Should You Use uniform bucket-level access](https://cloud.google.com/storage/docs/uniform-bucket-level-access#should-you-use)
* }
* @codingStandardsIgnoreEnd
* @return Bucket
Expand Down
12 changes: 6 additions & 6 deletions Storage/tests/System/IamConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public function setUp()
$this->guzzle = new Client;
}

public function testBucketPolicyOnly()
public function testUniformBucketLevelAccess()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX));
$bucket->update($this->bucketConfig());

$this->assertTrue($bucket->info()['iamConfiguration']['bucketPolicyOnly']['enabled']);
$this->assertTrue($bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']);

$bucket->update($this->bucketConfig(false));

$this->assertFalse($bucket->info()['iamConfiguration']['bucketPolicyOnly']['enabled']);
$this->assertFalse($bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']);
}

/**
* @expectedException Google\Cloud\Core\Exception\BadRequestException
*/
public function testBucketPolicyOnlyAclFails()
public function testUniformBucketLevelAccessAclFails()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX));
$bucket->update($this->bucketConfig());
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testObjectPolicyOnlyAclFails()
$object->acl()->get();
}

public function testCreateBucketWithBucketPolicyOnlyAndInsertObject()
public function testCreateBucketWithUniformBucketLevelAccessAndInsertObject()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX), $this->bucketConfig());

Expand All @@ -116,7 +116,7 @@ private function bucketConfig($enabled = true)
{
return [
'iamConfiguration' => [
'bucketPolicyOnly' => [
'uniformBucketLevelAccess' => [
'enabled' => $enabled
]
]
Expand Down