Subject resolution
composer require langsys/laravel-access-guard On each authorize() call, Access Guard:
- checks for a super admin (the resolved user implements
AuthorizableandisSuperAdmin()is true) → allow; - otherwise picks the API key if one is present on the request, else the authenticated user;
- runs the key path (
keyHasPermissionandkeyBelongsToEntity) or the user path (userRoleInEntity→ the role’shasPermission, and notuserHasDisabledEntity).
By default the user comes from Auth::user() and the API key from the api_key request attribute (set by langsys/laravel-api-keys). Override either from a service provider:
AccessGuard::resolveUserUsing(fn () => /* ... */);AccessGuard::resolveApiKeyUsing(fn () => /* ... */);