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

Filament Shield Laravel Package

bezhansalleh/filament-shield

Shield adds complete access management to Filament panels: resource, page, and widget permissions, custom permissions, and automatic policy generation, with per-resource policies and seamless role integration.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. Shield is a thin orchestration layer over spatie/laravel-permission, which is the de facto authorization primitive in the Laravel ecosystem. Architecturally it does three things: (1) emits permission keys and policies derived from Filament's discovered Resources/Pages/Widgets, (2) ships an admin UI/plugin for role→permission assignment, and (3) intercepts authorization via a super-admin Gate::before and generated policies. That is a good fit for us because the runtime dependency is a mature package we would likely adopt anyway; Shield is largely build-time tooling plus an optional admin panel. The risk concentration is not in the authorization engine but in the code-generation contract it imposes on our permission naming and policy files.

Integration feasibility. Low friction on paper: composer require, publish config, set auth_provider_model, add HasRoles to User, run interactive shield:setup. Constraint is tight coupling to Filament's major version: the 4.x line targets Filament 4.x and 5.x, and prior lines were separate rewrites (2.x→3.x→4.x). Feasibility therefore reduces to a single gating question — do we control our Filament major, and can we accept upgrading this package in lockstep with it?

Technical risk.

  • Breaking rewrite history. The current line is explicitly not backward compatible with 3.x/4.x-beta. If we are already on an older Shield, this is a migration project, not an upgrade.
  • Permission keys are a data contract. case + separator + subject determine the strings persisted in permissions, role_has_permissions, and model_has_permissions. Changing them post-production requires a data migration. The config also throws InvalidArgumentException on incompatible separator/case pairs (e.g. _ with snake) — an easy boot-time failure from a copy-pasted config.
  • Name collisions. Two resources backed by same-named models in different namespaces generate identical keys by default; mitigation is a buildPermissionKeyUsing callback. This is the single most likely source of silent privilege bleed in a large panel.
  • Privilege escalation surface. Super-admin role/gate interception bypasses every policy. A wrong role name or an enabled flag left on is a full authorization bypass, not a degraded mode.
  • Generated policies vs. hand-written. Policy placement rules are non-trivial (nested app/Models → mirrored Policies; vendor models → flat; module/DDD Models dirs → sibling Policies; legacy → flat). Only one of those rows is reliably found by Laravel's discovery without registration — assume manual Gate::policy wiring for module layouts.
  • Metadata anomalies. 2.8k stars but zero recorded dependents and a last-release date of 2026-07-25 suggest incomplete ecosystem telemetry or a pre-dated tag. Treat both as unverified until Composer resolves the constraint in our own lockfile.
  • Bus factor. Effectively single-maintainer, community-supported. MIT gives us fork rights, which is the only real mitigation.

Key questions. Which Filament majors and how many panels do we run? Is spatie/laravel-permission already live (with existing roles to migrate) or greenfield? Do we use spatie teams / Filament multi-tenancy? Are policies generated-and-committed or hand-authored with Shield skipped? Do we need externally managed permissions (Keycloak/Okta-style, handled by returning null from the key builder)? What is our definition of super admin, and is it auditable?

Integration Approach

Stack fit. The dependency chain is Filament → Shield → spatie/laravel-permission. Confirm the lockfile resolves Shield 4.x against our Filament constraint before any design work; if we are on Filament 3.x, Shield 3.x is the only supported pairing and should be treated as a separate, older codebase with a known migration cliff ahead of it. On a greenfield panel the fit is clean and we should adopt it. On a panel with hand-rolled is_admin flags or custom gates, plan to reconcile, not replace, semantics.

Migration path. Order of work: (1) inventory Resources/Pages/Widgets and all existing authorization mechanisms, producing a role × resource × action matrix as the target state; (2) decide and freeze the permission key convention — an ADR covering case, separator, subject, and the collision callback for namespaced duplicates; (3) run shield:generate in a scratch branch and review the emitted permission catalogue and policies as code, not as output; (4) diff generated policies against any existing hand-written ones and decide per-model whether merge is safe or the policy should be skipped; (5) seed roles via shield:seeder in staging; (6) cut over in production with the super-admin gate enabled first and role grants phased.

Compatibility. Two axes. Upward: Shield 4.x covers Filament 4.x and 5.x, so a Filament 5 upgrade stays within the support window — but it is still a coordinated bump, not a silent one. Downward: any pre-existing Shield 3.x install cannot be upgraded in place; budget a dedicated migration ticket. Internally, HasRoles on the auth provider and the correct auth_provider_model in config are hard prerequisites — get them wrong and authorization fails open or throws, depending on path.

Sequencing. Do not enable multi-tenancy in the same release as initial rollout. Land single-tenant authorization, verify with the matrix, then layer Filament tenancy plus Shield's tenancy config as an isolated change. Keep shield:generate and shield:seeder out of CI/CD pipelines; they are developer commands and should only ever run locally or in a reviewed PR. Verify the "prohibited commands" safe-guard is enabled in production config — it is our protection against a stray generation run overwriting curated permissions.

Operational Impact

Maintenance. The dominant cost is version-lockstep with Filament majors. Historical pattern is a full rewrite per Filament major, so plan for one non-trivial upgrade every ~12–18 months and pin Shield to an exact minor. Generated policies must be treated as reviewed artifacts under VCS; any drift between generated and committed state is a maintenance smell. Policy file placement differs by model location, so module/DDD layouts will need explicit Gate::policy registration maintained by hand.

Support. Community-only, no vendor SLA. GitHub issues, changelog, releases. With a single dominant maintainer, we should budget internal ownership of the integration surface (config, key convention, policy wiring) rather than assuming upstream will absorb our edge cases. Forkability under MIT is the contingency.

Scaling. Permission volume scales as resources × actions (default policy method list is 12), multiplied again by tenant count if teams are enabled. A 200-resource panel is ~2,400 permission rows and a correspondingly large role-permission join table. Two hot spots: spatie's permission cache must be reset in deploy hooks after seeding (permission:cache-reset), and the Shield admin resource itself becomes a high-value target — restrict who can reach the role-assignment UI, and consider not publishing it in tenant-facing panels.

Failure modes to instrument.

  • Super-admin gate misconfiguration → complete bypass. Add an automated test asserting a non-super-admin is denied on a sampled resource.
  • Stale permission cache after deploy → users see correct UI but get 403s (or retain revoked access). Cache reset in the release pipeline.
  • Separator/case conflict → boot-time exception; caught by a config unit test.
  • Duplicate permission keys for same-named namespaced resources → cross-tenant or cross-domain access. Caught by asserting key uniqueness in the catalogue.
  • Policy regeneration overwriting bespoke logic → silent loss of business rules; mitigated by PR review of generated diffs and skip config for curated models.
  • Missing HasRoles trait or wrong auth_provider_model → authorization evaluated against the wrong model; caught by a smoke test on login.

Ramp-up. For developers fluent in Filament, days — the UI and commands are discoverable and shield:setup is interactive. For security review and operations, allow one to two weeks: they need the key convention ADR, the role matrix, a runbook for seeding and cache resets, and an explicit statement of what super admin bypasses. Ship the runbook with the first release, not after the first incident.

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.
thomas-0816/doctrine-dbal-duckdb
moyisoft/laravel-admin
oxygen/mod-pages
oxygen/mod-import-export
oxygen/mod-media
ksoft/laravel-contentbuilderjs
ourgoldpackages/exchange
mikkimike/laravel-exchange1c
wandesnet/mercadopago-laravel
tsfcorp/email
larafony/core
laravel-enso/currencies
tartan/laravel-online-payment
wedevbr/celcoin-laravel
surazdott/nepali-date
devsquad-cockpit/laravel
coding-socks/laravel-upload-handler
artisanbarista/laravel-shield
instance-code/repository
flooris/prestashop-models