Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Authz Laravel Package

casbin/laravel-authz

Casbin Laravel Authz brings Casbin's powerful RBAC/ABAC access control to Laravel. Define policies, protect routes with middleware, integrate gates, cache decisions, and manage rules via Artisan commands—all with familiar Laravel conventions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. laravel-authz is a thin service-provider wrapper around the PHP-Casbin core (php-casbin/php-casbin), which means authorization decisions are computed by an external policy engine rather than by Laravel's native Gate/Policy classes. The model is clean: a declarative model.conf defines the authorization logic (ACL, RBAC, RBAC-with-domains, ABAC matchers), and a policy store (file, database, or cached adapter) holds the rules. The package binds an Enforcer into the service container, exposes a facade, and ships middleware so enforcement can sit in the request pipeline or be called explicitly in controllers/services. For a TPM this is attractive because authorization logic becomes configuration and data rather than application code — policy changes don't require a deploy — and the same mental model works across dozens of endpoints.

The main architectural caveat is coexistence. Laravel already has a first-class authorization system, and this package does not replace it so much as sit alongside it. Running two authorization systems in one codebase is a durable source of bugs and audit findings unless the boundary is drawn deliberately (e.g., Gates for coarse role gating and UI affordances, Casbin for fine-grained, resource-scoped, or attribute-driven decisions). That boundary decision is a design task, not a library task, and it should be made explicitly before adoption rather than discovered later.

Integration feasibility. Low. Installation is a Composer require, a config publish, optionally a migration for the rules table if you use the database adapter, and registering the middleware. There is no invasive refactor required. The real integration work is authoring the model and seeding the policy store from whatever exists today (roles table, hardcoded checks, LDAP groups).

Technical risk.

  • Upstream health. 341 stars is modest but consistent with an application-level library; the "0 dependents" figure is expected for packages consumed by applications rather than other packages, but it does mean there is no downstream ecosystem exercising version compatibility on your behalf. The php-casbin core is the more heavily used artifact and carries most of the technical weight.
  • Release metadata anomaly. The listed last release date is in the future (2026-09-27). Either the source data is stale/misparsed or a scheduled/backdated tag exists. Verify against Packagist and the GitHub tag list before treating the project as actively released.
  • Performance characteristics. Enforcer construction and policy loading have a per-request cost that is negligible at small policy volumes and material at large ones. ABAC matchers that dereference model attributes can introduce N+1 query patterns if the attribute loader is naive.
  • Cache coherence. Cached adapters (Redis et al.) are effectively mandatory at scale, and cache invalidation across nodes is where most production incidents will originate.
  • Bus factor. Governance is a small open-source org; no commercial SLA attaches to this package.

Key questions to resolve.

  1. Which Laravel and PHP versions are supported by the current tagged release, and what is the tested matrix in CI?
  2. Does the wrapper integrate with Laravel's Gate (e.g., as a user/ability resolver), or is it strictly parallel?
  3. Which adapters are supported out of the box, and is a cached/watched adapter available for our datastore?
  4. Is multi-tenancy (Casbin domains) supported through the wrapper's config, or does it require custom plumbing?
  5. What is the project's security-advisory history and disclosure process?
  6. Is there any first-party or sponsored support arrangement, or is it community-only?

Integration Approach

Stack fit. Strong for Laravel monoliths and Laravel-based APIs where authorization requirements are outgrowing hand-written Gates — particularly multi-tenant scoping, hierarchical resources, or rules that product/ops wants to change without engineering involvement. Weak fit for a single-role, three-permission application, where the added concept count is not repaid.

Migration path. Do not rip out Gates. Run Casbin in shadow mode first: evaluate both systems for every guarded action, log disagreements with request context, and let only the existing Gate make the real decision. This produces a discrepancy backlog that doubles as a policy-seeding specification and is the single highest-value risk-reduction step available. Once the disagreement rate is acceptably low on a bounded domain (e.g., document permissions in one product area), flip that domain to Casbin-authoritative, then proceed domain by domain.

Compatibility. Pin both the wrapper and php-casbin core explicitly; treat the pair as one versioned unit. Treat model.conf as code — version-controlled, reviewed, deployed with the app. If the existing schema already encodes roles and permissions, write a one-way exporter into the Casbin policy table rather than pointing Casbin at existing tables with a bespoke adapter; custom adapters are a maintenance liability and hide schema coupling.

Sequencing.

  1. Two-week spike: install in a branch, model one real domain, measure enforcer/policy-load cost under production-like policy volume.
  2. Decide the Gate/Casbin boundary in writing; socialize with security.
  3. Author model and policy schema; build the seeding exporter from current role data.
  4. Enable caching adapter and define the invalidation mechanism.
  5. Shadow-mode rollout with discrepancy logging (2–4 weeks of traffic).
  6. Domain-by-domain cutover behind a feature flag; keep a documented rollback to Gate.
  7. Build or buy policy administration tooling — this is frequently underestimated and is where the ongoing value (or the ongoing pain) lives.

Operational Impact

Maintenance. Apache-2.0, permissive, no license friction. The steady-state maintenance burden is not dependency upgrades — those are routine — but policy hygiene: the policy table becomes a production dataset that nobody owns by default. Assign an explicit owner and an access-review cadence from day one, or the authorization store will drift into an unauditable state faster than application code would.

Support. Community-supported through GitHub issues; no SLA. Escalation for a production authorization outage is "read the source." For a system on the critical path of every request, budget internal expertise rather than assuming upstream responsiveness.

Scaling. Enforcement is stateless and horizontally friendly, but every node holds a policy snapshot. Two scaling axes matter: policy size (enforcer load time and memory per worker — benchmark at your realistic rule count, not at demo scale) and policy change rate (cache invalidation fan-out). High rule counts with frequent updates is the combination that hurts.

Failure modes to design for explicitly.

  • Policy store unreachable. The fail-open/fail-closed decision must be made by security, documented, and implemented deliberately. Default behavior should be deny, with an explicit, logged break-glass path if the business requires one.
  • Stale cache. Manifests as either privilege creep (revoked access still granted) or lockout (newly granted access denied). Both are user-visible; the first is a security event.
  • Malformed or invalid model. A syntax error in model.conf can deny all traffic or throw on every request. Gate model changes behind the same CI validation you would apply to code, plus a canary deploy.
  • Watcher/notification failure. Silent divergence between nodes; needs a health check and an alert on snapshot age.
  • Attribute-loader failure under ABAC. External data dependencies turn an authorization check into a distributed transaction; apply timeouts and a defined degradation behavior.

Ramp-up. Casbin's model DSL (matchers, effects, role inheritance semantics) is genuinely unfamiliar to most Laravel developers and is the dominant onboarding cost — realistically one to two weeks to productive, longer to confident. Budget for internal worked examples mapped to your actual domains, a short written standard for authoring policies, and a runbook covering cache flush, policy rollback, and emergency revocation. The operational cost of this package is not in the code you write to adopt it; it is in the governance, tooling, and on-call literacy you must stand up around the policy store afterward.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource