Skip to content

[13.x] Add middleware attribute#1897

Merged
taylorotwell merged 2 commits intolaravel:13.xfrom
axlon:authorize-token-attribute
Mar 21, 2026
Merged

[13.x] Add middleware attribute#1897
taylorotwell merged 2 commits intolaravel:13.xfrom
axlon:authorize-token-attribute

Conversation

@axlon
Copy link
Copy Markdown
Contributor

@axlon axlon commented Mar 19, 2026

Inspired by laravel/framework#59048

This PR adds a new attribute that allows developers to easily set token scopes in their controllers, example usage:

class MyController
{
    #[TokenCan('read')]
    public function index() { /* ... */ }

    #[TokenCan('write')]
    public function store() { /* ... */ }
}

Note: I opted not to name it Scope because that would conflict with an existing Eloquent attribute

@axlon
Copy link
Copy Markdown
Contributor Author

axlon commented Mar 19, 2026

From what I can tell static analysis is failing because the shared workflow is pinned to PHP 8.2, which causes Composer to install Laravel 12, where the new Middleware attribute doesn't exist

@taylorotwell taylorotwell changed the title [13.x] Add AuthorizeToken middleware attribute [13.x] Add middleware attribute Mar 21, 2026
@taylorotwell taylorotwell merged commit 1894e49 into laravel:13.x Mar 21, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants