Laravel Helper for API Endpoint Permissions
berthott/laravel-api-permissions is a Laravel package for laravel helper for api endpoint permissions.
It currently has 1 GitHub stars and 1.051 downloads on Packagist (latest version 3.0.4).
Install it with composer require berthott/laravel-api-permissions.
Discover more Laravel packages by berthott
or browse all Laravel packages to compare alternatives.
Last updated
A helper for API Permissions in Laravel. Protect all your routes with a single middleware.
$ composer require berthott/laravel-api-permissions
models.action.permissions middleware to the routes you want to protect.php artisan make:seeder PermissionTableSeederberthott\Permissions\Helpers\PermissionsHelper to actually seed the permissions
PermissionsHelper::resetTables() will truncate all permission related tables.PermissionsHelper::buildRoutePermissions() will build the permissions table. You might pass an array for mapping routes to permissions. E.g.
[
'*.destroy' => [
'*.destroy',
'*.destroy_many'
],
]
PermissionsHelper::buildUiPermissions() will add UI permissions, that will only be handle by the frontend.migrate option is true the package will migrate five tables for you: roles, role_user, permissions, permissionables and permission_routes.migrate option is false and you want to write your own migration you can have look at the default migrations by running$ php artisan vendor:publish --provider="berthott\Permissions\ApiPermissionsServiceProvider" --tag="migrations"
permissions to your User model by adding the HasPermissions trait.roles to you User model by adding the HasRoles trait.ignoreActions config, or by added the IgnorePermissionRoutestrait.To change the default options use
$ php artisan vendor:publish --provider="berthott\Permissions\ApiPermissionsServiceProvider" --tag="config"
namespace: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults to App\Models.namespace_mode: Defines the search mode for the namespaces. ClassFinder::STANDARD_MODE will only find the exact matching namespace, ClassFinder::RECURSIVE_MODE will find all subnamespaces. Defaults to ClassFinder::RECURSIVE_MODE.prefix: Defines the route prefix. Defaults to api.middleware: An array of all middlewares to be applied to all of the generated routes. Defaults to [].ignoreActions: Defines an array of actions that should be ignored by default. Defaults to [].migrate: Defines wether or not to migrate standard tables.. Defaults to true.Tested with Laravel 10.x.
See License File. Copyright © 2023 Jan Bladt.