Skip to main content

daravel_permission 1.15.0 copy "daravel_permission: ^1.15.0" to clipboard
daravel_permission: ^1.15.0 copied to clipboard

Roles and permissions in the database for Daravel, on spatie/laravel-permission's tables, with middleware, gate integration and an in-memory cache.

Daravel

daravel_permission #

English · Bahasa Indonesia

Roles and permissions in the database for Daravel, on the five tables of spatie/laravel-permission v6: a Laravel application using Spatie and a Daravel application share them, and a role given by either is seen by the other.

dart pub add daravel_permission
// bootstrap/app.dart
import 'package:daravel_permission/daravel_permission.dart';

Application createApp() => Application.configure(basePath: '.')
    .withPermissions()
    .withMigrations([...migrations, const CreatePermissionTables()])
    // ...
    .create();

final class User extends Model with AuthenticatableModel, HasRoles { /* ... */ }
await user.assignRole('writer');
await user.hasPermissionTo('posts.edit');
router.get('/admin', admin.index).middleware(['auth', 'role:admin|editor']);
  • HasRoles, Role and Permission with Spatie's methods, exceptions and 403 messages; the role, permission and role_or_permission middleware; a gate hook, so Gate.allows and can: see permissions.
  • Guards, opt-in wildcards (posts.*) and super-admin role, and the permission:* commands.
  • An in-memory cache: a check is a set lookup, and changes reach every isolate and process (every server, with a shared cache store) within a second.
  • Tested on SQLite, PostgreSQL and MariaDB, and against Laravel 12 with Spatie 6.

Documentation: https://github.com/daravel-dev/daravel/blob/main/docs/guide/permissions.md.

License and trademarks #

MIT. "Laravel" is a trademark of Laravel Holdings Inc.; "Dart" is a trademark of Google LLC. spatie/laravel-permission is Spatie's MIT-licensed package; Daravel only shares its database layout. Daravel is an independent project, not affiliated with or endorsed by any of them.

0
likes
160
points
0
downloads

Documentation

Documentation
API reference

Publisher

verified publisherframework.daravel.dev

Weekly Downloads

Roles and permissions in the database for Daravel, on spatie/laravel-permission's tables, with middleware, gate integration and an in-memory cache.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#rbac #permissions #authorization #server #backend

License

MIT (license)

Dependencies

args, daravel, dartisan_cli

More

Packages that depend on daravel_permission