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 Passport Scopes Restriction Laravel Package

denniseilander/laravel-passport-scopes-restriction

Restrict which OAuth scopes users can request with Laravel Passport. Assign allowed scopes per user or model and enforce them during token issuance, so clients can't obtain permissions they shouldn't have—keeping API access tightly scoped with minimal setup.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

What the release actually is: 3.0.1 is a maintenance patch. Three of the four changelog entries are Dependabot bumps to GitHub Actions used in CI (dependabot/fetch-metadata 2.1.0→2.3.0, codecov/codecov-action 4.5.0→4.6.0). None of these affect the shipped package code. The one substantive change is Laravel 12 support (PR #58), which widens the framework version constraint rather than altering behavior.

Architecture fit: The package is a narrow, single-purpose extension to Laravel Passport — it constrains which OAuth scopes a client/request may obtain. It sits in the authorization/token-issuance path, which is exactly where you want an explicit policy layer rather than scattering scope checks across controllers. Fit is good for teams already standardized on Passport; it is irrelevant if you use Sanctum or a third-party IdP (Auth0, Keycloak, Cognito).

Integration feasibility: Low effort by design — Composer install, publish config, register middleware, declare scope mappings. No database migrations or queue workers implied. The real cost is not installation but validation: you must prove the restriction behaves correctly across every grant type you use (authorization code, password, client credentials, personal access tokens, refresh).

Technical risk:

  • Solo maintainer / low bus factor. Single-author project with a thin release cadence. Mitigate by treating it as forkable (confirm MIT license) and vendoring or forking if it goes stale.
  • Coupling to Passport internals. Scope handling has shifted across Passport majors; a package that patches or decorates Passport behavior is exposed to upstream refactors. Laravel 12 support landing in a patch release (3.0.1) rather than a minor is a signal that versioning here is loose — do not assume semver discipline protects you.
  • Security-sensitive blast radius. A defect here is either an over-permission (privilege escalation, audit finding) or an under-permission (production auth outage). Both are high-severity, so this cannot be adopted on the strength of the changelog alone.
  • CI-only dependency churn creates noise; it tells you nothing about runtime quality and should not be read as a stability signal.

Key questions to resolve before adoption:

  1. Which Laravel/Passport version pairs are in the tested matrix, and is Laravel 12 actually exercised in CI or just allowed by the constraint?
  2. Does the restriction fail closed (deny on unknown/misconfigured scope) or open? Fail-open is disqualifying for a security control.
  3. Where is enforcement applied — token endpoint, middleware on protected routes, or both? Can it be bypassed by a grant type it does not cover?
  4. Test coverage and whether tests assert denial paths, not just happy paths.
  5. Is the scope map config-cache compatible (php artisan config:cache) and deployable without a rebuild?
  6. License and maintainer responsiveness on security reports.

Integration Approach

Stack fit: Laravel 11/12 + Passport, PHP 8.2+. Confirm your pinned Passport major is inside the supported range — Laravel 12 support does not automatically mean Passport 13 support.

Migration path: There is nothing to migrate from if scope restriction is currently manual; the work is consolidation. If you already enforce scopes in middleware or controllers, run this package in parallel (shadow mode) first: let it evaluate and log denials without enforcing, compare against existing behavior for a full traffic cycle, then flip to enforcing. That converts an auth-path change from a leap of faith into a diff.

Compatibility checks:

  • Verify constraint resolution with composer why-not against your locked Laravel and Passport versions before merging.
  • Confirm no conflict with existing Passport customization (custom grants, token repositories, existing scope middleware).
  • Check that published config merges cleanly with your config-cache pipeline and per-environment overrides.

Sequencing:

  1. Spike in a scratch branch; enumerate every grant type and client in use.
  2. Write integration tests that assert denial for out-of-policy scopes per grant type — this is the acceptance gate.
  3. Shadow-mode deploy to staging, then production, with denial logging.
  4. Enforce; pin the version explicitly (3.0.1, tilde constraint at most) and add a changelog watch.
  5. Document the scope map as owned configuration, not as package internals.

Operational Impact

Maintenance: Steady-state cost is low — config plus a middleware registration. The recurring cost is upstream tracking: every Passport or Laravel major requires re-validating this package, and given the patch-level Laravel 12 support, you should assume you may need to contribute the compatibility PR yourself. Budget a small recurring allowance rather than assuming zero.

Support: Community-only, no SLA, no vendor. Escalation path is "open an issue, or fork." For a security control in the auth path, name an internal owner who can read the source and patch it.

Scaling: Negligible runtime cost — an in-request scope comparison, no extra I/O if the scope map is cached. It will not be a throughput bottleneck at any realistic request volume. The scaling concern is organizational, not technical: the scope map becomes a shared artifact that every new client and endpoint must be added to, and stale maps silently accumulate.

Failure modes:

  • Over-permission: misconfigured or missing scope entry grants more than intended — the dangerous, quiet failure. Mitigate with deny-by-default tests and periodic audit of issued tokens vs. declared scopes.
  • Under-permission / outage: a config change or upstream upgrade blocks legitimate clients at token issuance; symptoms look like widespread 401s. Mitigate with staged rollout and a documented rollback that does not require a code deploy.
  • Silent bypass: a grant type or route outside the middleware's coverage continues unrestricted. Enumerate coverage explicitly.
  • Upstream drift: Laravel/Passport upgrade breaks enforcement without a test failure if denial paths are untested.

Ramp-up: Any Laravel developer can install and configure this in well under a day. The genuinely skilled part — deciding the scope policy itself and proving it holds across grant types — is 2–4 days of engineer time plus security review, and that cost is yours regardless of the package. Frame adoption as policy work with a small library attached, not as a dependency decision.

Verdict on 3.0.1: Not a feature release and not a breaking change; no re-assessment of behavior is required. Its only material effect is unblocking Laravel 12 upgrades for teams already using the package. Adoption decision should rest on the security-validation questions above, not on this changelog.

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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums