Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed Dec 16, 2022
1 parent 4b93303 commit 8fa065d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
36 changes: 0 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
1 change: 0 additions & 1 deletion src/Concerns/HasArn.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace RenokiCo\Acl\Concerns;

use RenokiCo\Acl\Arn;
use Illuminate\Support\Str;

trait HasArn
{
Expand Down
8 changes: 4 additions & 4 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand Down

0 comments on commit 8fa065d

Please sign in to comment.