JosephSilber/bouncer
Laravel Eloquent roles and abilities.
Thành tựu nổi bật
Những danh hiệu mới nhất của dự án
#1 Repository Của Tháng
#1 Repository Của Tháng
#1 Repository Của Tháng
🔐 Bouncer — Quản lý roles và abilities cho Eloquent với cú pháp ngắn gọn
"An elegant, framework-agnostic approach to managing roles and abilities for any app using Eloquent models."
Bouncer là package PHP của JosephSilber, cung cấp cách tiếp cận nhẹ nhàng và linh hoạt để quản lý vai trò (roles) và quyền hạn (abilities) cho bất kỳ ứng dụng nào sử dụng Eloquent models. Dù đang dùng Laravel hay standalone, Bouncer đều hoạt động như một lớp trung gian mỏng giữa logic xác thực của bạn và Eloquent.
✨ Điểm nổi bật
- Framework-agnostic: hoạt động độc lập với Laravel, chỉ cần Eloquent models
- Tích hợp Laravel Gate: tự động được consult khi kiểm tra authorization tại gate
- Cú pháp biểu đạt ngắn gọn:
Bouncer::allow($user)->to('create', Post::class)— một dòng cấp quyền - Hỗ trợ role lẫn ability trực tiếp: gán quyền qua role hoặc trực tiếp cho user
- Abilities theo model cụ thể: giới hạn quyền trên từng instance model, không chỉ class-level
- Multi-tenancy: scope middleware tùy chỉnh phạm vi roles/abilities theo tenant
- Cache: hỗ trợ cache roles/abilities để tối ưu hiệu năng
- Blade directives: directive riêng để kiểm tra quyền trực tiếp trong view
- Console command
bouncer:clean: dọn dẹp dữ liệu roles/abilities không còn cần thiết
💡 Vì sao đáng chú ý
Bouncer không phải một hệ thống ACL nặng nề với hàng chục cấu hình. Thay vào đó, nó tập trung vào một ý tưởng đơn giản: cho phép hoặc từ chối quyền ở mức độ chi tiết (model-specific) mà vẫn giữ cho code dễ đọc. Code của ứng dụng luôn được ưu tiên hơn Bouncer — nếu logic app cho phép một hành động, Bouncer sẽ không can thiệp.
Điểm mạnh nhất của Bouncer nằm ở khả năng mở rộng: bạn có thể bắt đầu với vài role đơn giản, sau đó thêm abilities gắn với từng model cụ thể, rồi đến multi-tenancy mà không cần thay đổi kiến trúc. Hỗ trợ cache và scope middleware giúp nó phù hợp cả với ứng dụng nhỏ lẫn hệ thống đa tenant quy mô lớn.
#Laravel #Authorization #Eloquent #PHP #ACL #Permissions #TiniX
Dự án tương tự
Khám phá các dự án và mô hình AI khác có sự tương đồng.
The easiest and most intuitive way to add access management to your Filament Panel; Resources, Pages & Widgets through `spatie/laravel-permission`
一个在 ThinkPHP 中支持 ACL、RBAC、ABAC 等访问控制模型的授权库。An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP.
Apache Casbin: an authorization library that supports access control models like ACL, RBAC, ABAC.
CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access
An open-source authorization as a service inspired by Google Zanzibar, designed to build and manage fine-grained and scalable authorization systems for any application. — Permify is now part of FusionAuth 🎉
The most scalable and customizable permission server on the market. Fix your slow or broken permission system with Google's proven "Zanzibar" approach. Supports ACL, RBAC, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.