Download the PHP package libinkk/permission without Composer
On this page you can find all versions of the php package libinkk/permission. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download libinkk/permission
More information about libinkk/permission
Files in libinkk/permission
Package permission
Short Description Production-grade Laravel authorization engine (v1.0) with RBAC, ABAC, multi-tenancy, temporary access, delegation, audit logs, and Vue/React helpers.
License MIT
Homepage https://www.libinkk.in
Informations about the package permission
libinkk/permission
v1.0 — production-grade Laravel authorization engine.
RBAC + ABAC + tenants + temporary access + delegation + explainable decisions + layered cache.
Authorization that explains itself.
Most permission packages answer: Does this user have this permission?
This package answers:
Is this user allowed to perform this action on this resource, in the current scope, under the current conditions — and if not, why?
This is not a thin roles CRUD helper. Blade, Vue, React, and Filament are UI only. Every write path must go Laravel → this package → ALLOW / DENY.
| Doc | Purpose |
|---|---|
| This README | Tutorials and API |
| UPGRADE.md | 0.x → 1.0 |
| SECURITY.md | How to report issues |
| CHANGELOG.md | Release history |
| docs/tutorial.md | SEO tutorial for www.libinkk.in/permission |
| docs/deployment.md | Production checklist |
| docs/benchmarks.md | Cache / query notes |
Contents
- Compatibility
- Installation
- Tutorial 1 — Blog in 15 minutes
- Tutorial 2 — Invoice approval (ABAC + delegation)
- Tutorial 3 — Multi-tenant SaaS
- Permission naming
- Roles and users
- Wildcards, hierarchy, deny
- Conditions, ownership, policies
- Guards
- Temporary access and delegation
- Audit, history, versioning
- Middleware
- Blade
- Vue
- React
- Authorization API
- Filament
- Discovery
- Debugger and Artisan
- Bulk, cache, performance
- Testing
- Security
- Troubleshooting
- Architecture
Compatibility
| Laravel | PHP |
|---|---|
| 10 | 8.1 – 8.3 |
| 11 | 8.2 – 8.4 |
| 12 | 8.2 – 8.5 |
| 13 | 8.3 – 8.5 |
Package version: Libinkk\Permission\Version::VERSION → 1.0.0.
CI: .github/workflows/tests.yml.
Installation
Or publish by hand:
Set permission.database.primary_key to bigint (default), uuid, or ulid before the first migrate.
Add the trait. The package does not own users. Assignments are user_type / user_id.
Tutorial 1 — Blog in 15 minutes
Goal: editors can write posts, admins can delete, guests cannot.
1. Define permissions
Or:
2. Create roles
3. Assign and check
4. Protect routes
5. Hide UI (not a grant)
6. Still check in the controller
@can only hides the link. authorize() / middleware is the security boundary.
Tutorial 2 — Invoice approval (ABAC + delegation)
Goal: finance managers approve invoices under their limit. A manager on leave can delegate.
Delegate for four hours (delegator must already hold the permission):
Only the delegator can revoke. Self-delegation is rejected. If the manager later loses invoice.approve, the cover user loses it too.
Explain in the terminal:
Tutorial 3 — Multi-tenant SaaS
Goal: the same user is an editor in Org A and a viewer in Org B.
Nested scopes (organization → workspace):
On every HTTP request (middleware):
Queue jobs must set the tenant again. Global roles (assignRole('super-admin') with no tenant) cross tenants only when teams.global_roles.cross_tenant is true.
Permission naming
Format: resource.action
Names that contain . are managed by this package through Gate::before.
Roles and users
System rows (is_system = true) cannot be deleted or unprotected.
Wildcards, hierarchy, deny
Exact matches beat wildcards. A wildcard does not cross resources (posts.* is not invoices.view).
Circular inheritance throws and is reported by permission:validate. Disable with hierarchy.enabled = false.
Default precedence:
Conditions, ownership, policies
.own also auto-checks author_id, user_id, owner_id, or permission.ownership.attribute.
Thrown or unknown conditions deny.
Laravel policies are not an engine step. Dotted abilities are resolved here. Use a host policy for non-dotted abilities, or call both yourself. POLICY_DENIED is reserved for that host wiring.
Guards
Roles and permissions have guard_name (default web). A web permission does not authorize an api user.
Temporary access and delegation
After expiry, can() is false with EXPIRED_PERMISSION or DELEGATION_EXPIRED.
Delegation rules: delegator must hold the permission; no self-delegate; no re-delegate; only the delegator revokes; expired/revoked never authorize.
Audit, history, versioning
Audit rows are append-only (no update / delete / soft delete).
Middleware
Aliases: permission, role.
Blade
Frontend checks are UI-only.
Vue
React
Authorization API
Off until permission.frontend.enabled is true.
/access is self-only unless frontend.access_user_permission is set (for example users.access) and the viewer can() that ability.
Filament
Not a Composer requirement. Set filament.enabled when Filament is installed.
Admin CRUD / matrix UI is a separate package (libinkk/permission-filament). Use FilamentAuthorization::debug() on a custom page for the debugger report.
Discovery
Debugger and Artisan
GET /api/authorization/explain?permission=… is off until debug.enabled. Current user only. Not a grant.
Bulk, cache, performance
Prefix: libinkk:permission:v1. Redis L3 is off until cache.redis.enabled is true.
| Data | Default TTL |
|---|---|
| Permissions / roles | 86400 |
| User roles / permissions | 3600 |
| Scopes | 1800 |
| Decisions | 300 |
Mutations invalidate after DB commit. Octane and queue workers flush request state each cycle.
Details: docs/benchmarks.md.
Testing
Permission::fake() is disabled in production unless permission.testing.allow_fake is true.
Security
- Fail closed.
- Database is source of truth.
- Never trust Blade / Vue / React / Filament for enforcement.
- No privilege escalation via cache, fakes, or client payloads.
- Tenant isolation when teams are on.
See SECURITY-CERTIFICATE.md (8.0 / 10, not a third-party cert).
Production settings: docs/deployment.md.
Configuration (defaults)
Troubleshooting
| Symptom | Check |
|---|---|
| Always deny | permission.enabled, user trait, permission:doctor |
| Tenant deny | AuthorizationContext::tenant() on the request; teams.require_context |
| Stale allow after revoke | permission:cache:clear; confirm after-commit ran |
| Wildcard too wide | Wildcards do not cross resources; prefer exact + deny |
| Delegation not working | Delegator must can() the permission now; not expired; not self |
| Fake in production | Blocked unless testing.allow_fake |
| Explain 404 | debug.enabled is false (default) |
| Frontend 404 | frontend.enabled is false (default) |
| UUID attach failed | Upgrade to 1.0 pivot id generation; set key type before first migrate |
Architecture
Tables
| Table | Purpose |
|---|---|
roles / permissions |
Definitions |
role_permissions |
Role ↔ permission (allow / deny) |
user_roles / user_permissions |
Polymorphic assignments + expiry |
role_inheritances |
Hierarchy |
permission_conditions / permission_condition_values |
ABAC |
scopes / *_scopes |
Hierarchical boundaries |
tenants / tenant_users |
Optional package tenants |
permission_delegations |
Delegated access |
permission_versions |
Snapshots |
authorization_audits |
Append-only log |
Soft deletes: roles and permissions only.
Events
RoleCreated / Updated / Deleted, PermissionCreated / Updated / Deleted, RoleAssigned / Removed, PermissionGranted / Revoked, AuthorizationAllowed / Denied, DelegationCreated / Revoked, PolicyChanged.
Roadmap
| Version | Status |
|---|---|
| v0.1 – v0.9 | Shipped in 1.0 |
| v1.0 | Docs, upgrade guide, CI matrix, production guide ✅ |
Package layout
Ecosystem
Integrates with Libinkk OneAuth, Modular, and API Starter without replacing auth or tenant models.
- Homepage: https://www.libinkk.in
- Support: [email protected]
- License: MIT © Libin K K
All versions of permission with dependencies
illuminate/auth Version ^10.0|^11.0|^12.0|^13.0
illuminate/cache Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/view Version ^10.0|^11.0|^12.0|^13.0