Skip to content

feat: Integrate Laravel's built-in authorization Gates #73

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

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

Dobmod
Copy link
Member

@Dobmod Dobmod commented Jul 5, 2024

- Integrate Laravel's built-in authorization Gates (php-casbin#70)
- Added guidance for Gates in README.md
$identifier = strval($identifier);

return Enforcer::enforce($identifier, ...$args);
});
Copy link
Member

Choose a reason for hiding this comment

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

This does not make full use of the Gate. Here the policy should be registered to the Gate.
We can check if a user has a permission with Laravel's default can function: $user->can('edit');

Therefore, the Gate check should be intercepted here:

Gate::before(function (User $user, string $act, $obj...) {});

Gate::after(function (User $user, string $act, $obj...) {});

See: https://laravel.com/docs/11.x/authorization#intercepting-gate-checks

And then

  1. Whether to use Gate is a configurable item
  2. Use after or before interception is also a configurable item

@Dobmod Dobmod force-pushed the feature-use-gates-1.0 branch 5 times, most recently from c565a05 to caadc76 Compare August 6, 2024 16:44
@Dobmod Dobmod force-pushed the feature-use-gates-1.0 branch from caadc76 to 3a3132a Compare August 6, 2024 16:48
@Dobmod Dobmod requested a review from leeqvip August 6, 2024 16:51
@leeqvip leeqvip merged commit 11ffe28 into php-casbin:master Aug 7, 2024
49 checks passed
@leeqvip
Copy link
Member

leeqvip commented Aug 7, 2024

🎉 This issue has been resolved in version 3.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants