From 8fa065dc23b6913860535feaa315f054a3a5fbc8 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Fri, 16 Dec 2022 09:20:14 +0200 Subject: [PATCH] tweaks --- README.md | 36 ------------------------------------ src/Concerns/HasArn.php | 1 - src/Statement.php | 8 ++++---- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 61b493a..1a7b675 100644 --- a/README.md +++ b/README.md @@ -213,42 +213,6 @@ $account->isAllowedTo('server:Delete', $server); // true As you have seen previously, on the actor instances you can specify the account identifier for them. In an ARN like `arn:php:default:local:123:server`, the part `123` is the account ID, or the account identifier. Thus, setting `resolveArnAccountId` to return `123`, the policies will allow the actor to `server:List` on that specific resource. -### Subpathing - -Some of your resources might allow subpathing, like having a disk where you would want to allow certain users to access certain files within that disk. - -```php -$policy = Acl::createPolicy([ - Statement::make( - effect: 'Allow', - action: 'disk:ReadFile', - resource: [ - 'arn:php:default:local:123:disk/etc/*', - ], - ), -]); - -$account->isAllowedTo('disk:ReadFile', 'arn:php:default:local:123:disk/etc/hosts'); // true -$account->isAllowedTo('disk:ReadFile', 'arn:php:default:local:123:disk/var/log/httpd.log'); // false -``` - -In case you would have a `disk:ListFilesAndFolders` action, keep in mind that subpaths must end with `/` to match the pattern: - -```php -$policy = Acl::createPolicy([ - Statement::make( - effect: 'Allow', - action: 'disk:ListFilesAndFolders', - resource: [ - 'arn:php:default:local:123:disk/etc/*', - ], - ), -]); - -$account->isAllowedTo('disk:ListFilesAndFolders', 'arn:php:default:local:123:disk/etc/'); // true -$account->isAllowedTo('disk:ListFilesAndFolders', 'arn:php:default:local:123:disk/etc'); // false -``` - ### Subpathing with ARNables > *In case it was not obvious, subpathing is not supported for resource-agnostic ARNs.* diff --git a/src/Concerns/HasArn.php b/src/Concerns/HasArn.php index 18a1133..a6b52e8 100644 --- a/src/Concerns/HasArn.php +++ b/src/Concerns/HasArn.php @@ -3,7 +3,6 @@ namespace RenokiCo\Acl\Concerns; use RenokiCo\Acl\Arn; -use Illuminate\Support\Str; trait HasArn { diff --git a/src/Statement.php b/src/Statement.php index 560dd42..b095a03 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -27,10 +27,10 @@ public static function make( $rootAccountId = null, ) { return new Statement( - $effect, - $action, - $resource, - $rootAccountId, + effect: $effect, + action: $action, + resource: $resource, + rootAccountId: $rootAccountId, ); }