-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from oat-sa/develop
Release v0.14.0
- Loading branch information
Showing
6 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace oat\awsTools; | ||
|
||
use League\Flysystem\AwsS3V3\VisibilityConverter; | ||
use League\Flysystem\Visibility; | ||
|
||
class BucketOwnerVisibilityConverter implements VisibilityConverter | ||
{ | ||
private const PUBLIC_GRANTEE_URI = 'http://acs.amazonaws.com/groups/global/AllUsers'; | ||
private const PUBLIC_GRANTS_PERMISSION = 'READ'; | ||
private const BUCKET_OWNER_ACL = 'bucket-owner-full-control'; | ||
|
||
public function __construct(private string $defaultForDirectories = Visibility::PUBLIC) | ||
{ | ||
} | ||
|
||
public function visibilityToAcl(string $visibility): string | ||
{ | ||
return self::BUCKET_OWNER_ACL; | ||
} | ||
|
||
public function aclToVisibility(array $grants): string | ||
{ | ||
foreach ($grants as $grant) { | ||
$granteeUri = $grant['Grantee']['URI'] ?? null; | ||
$permission = $grant['Permission'] ?? null; | ||
|
||
if ($granteeUri === self::PUBLIC_GRANTEE_URI && $permission === self::PUBLIC_GRANTS_PERMISSION) { | ||
return Visibility::PUBLIC; | ||
} | ||
} | ||
|
||
return Visibility::PRIVATE; | ||
} | ||
|
||
public function defaultForDirectories(): string | ||
{ | ||
return $this->defaultForDirectories; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters