Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
IT Security NachrichtenHMD 106 Pure: Ultra-Simpel-Handy startet für nur rund 10 Euro(28.09.2026 um 19:22 Uhr)
•
IT NachrichtenGalaxy S25 Ultra One UI 9 Updates: The Beginning(28.09.2026 um 19:20 Uhr)
•
IT NachrichtenKiteworks lifts shutdown order after incident-free weekend(28.09.2026 um 15:21 Uhr)
•••••
IT NachrichtenSpaceX's latest Starship mission reached low-Earth orbit(28.09.2026 um 19:14 Uhr)
•••
IT Security NachrichtenHMD 106 Pure: Ultra-Simpel-Handy startet für nur rund 10 Euro(28.09.2026 um 19:22 Uhr)
•
IT NachrichtenGalaxy S25 Ultra One UI 9 Updates: The Beginning(28.09.2026 um 19:20 Uhr)
•
IT NachrichtenKiteworks lifts shutdown order after incident-free weekend(28.09.2026 um 15:21 Uhr)
•••••
IT NachrichtenSpaceX's latest Starship mission reached low-Earth orbit(28.09.2026 um 19:14 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

Laravel Passport Modern Scopes – Attribute-Based OAuth Scope Enforcement

Laravel Passport traditionally enforces OAuth scopes at the routing level, usually via middleware definitions in route files. While this works, it often leads to: authorization rules scattered across routes controllers coupled to…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Laravel Passport traditionally enforces OAuth scopes at the routing level, usually via middleware definitions in

route files.



While this works, it often leads to:




  • authorization rules scattered across routes

  • controllers coupled to infrastructure concerns

  • duplicated or hard-to-review scope requirements

  • reduced clarity as APIs grow



Laravel Passport Modern Scopes introduces a different approach.



👉 https://github.com/N3XT0R/laravel-passport-modern-scopes









The idea: declare scopes where they matter



Instead of wiring scopes into routes, this package allows you to declare OAuth scope requirements directly on

controllers or controller actions
using PHP 8 attributes.



Authorization intent lives next to the code it protects.



Passport itself remains fully responsible for authentication and token validation.









Example






use N3XT0R\PassportModernScopes\Support\Attributes\RequiresScope;
use N3XT0R\PassportModernScopes\Support\Attributes\RequiresAnyScope;

#[RequiresScope('users:read')]
final class UserController
{
public function index()
{
// Requires users:read
}

#[RequiresAnyScope('users:update', 'users:write')]
public function update()
{
// Requires at least one of the given scopes
}
}






A single middleware inspects controller attributes at runtime and enforces them using Laravel Passport’s native

tokenCan checks.



Authentication itself remains the responsibility of your configured guard (e.g. auth:api).









What this package does




  • Enables attribute-based OAuth scope enforcement

  • Keeps routes clean and infrastructure-agnostic

  • Makes authorization requirements explicit and discoverable

  • Works with Passport’s existing scope validation

  • Requires no changes to Passport internals



Scopes are declared, not wired.









Why attributes?



Using PHP attributes for authorization requirements has several advantages:




  • Declarative and explicit

  • No duplication between routes and controllers

  • Easier to reason about during code review

  • Friendly to static analysis and documentation tools

  • No magic strings scattered across route definitions



This keeps authorization intent separate from HTTP wiring.









What this package does not do



To be explicit:




  • ❌ It does not replace Laravel Passport

  • ❌ It does not implement authentication

  • ❌ It does not introduce custom guards

  • ❌ It does not enforce business rules



It only resolves and enforces declared OAuth scope requirements.









Where this fits architecturally



Laravel Passport Modern Scopes is intentionally small and focused.



It pairs well with:




  • structured scope models (e.g. resource:action)

  • domain-level authorization logic

  • admin tooling that manages scopes centrally



It can be used standalone or alongside higher-level authorization libraries.









Installation






composer require n3xt0r/laravel-passport-modern-scopes:^2.0






The middleware is automatically registered via the package’s service provider.









Final thoughts



This package is about clarity, not abstraction.



If you prefer:




  • explicit authorization requirements

  • clean routes

  • controllers that express intent clearly



then attribute-based scope enforcement can be a very natural fit.



Feedback and discussion are welcome.



👉 https://github.com/N3XT0R/laravel-passport-modern-scopes

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Laravel Passport Modern Scopes – Attribute-Based OAuth Scope Enforcement

Thematisch verwandte Begriffe: Laravel, Passport, Modern, Scopes · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-101073 | A security flaw has been discovered in Netcore NR289-GE 1.4.5102. Impac…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag