Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The prependToMiddlewarePriority method removes middleware added previously using pushMiddlewareToGroup. #42601

Closed
crotanite opened this issue Jun 1, 2022 · 1 comment

Comments

@crotanite
Copy link

  • Laravel Version: 9.15.0
  • PHP Version: 8.1.3
  • Database Driver & Version: MySQL 8.0.28

Description:

[Previously noted in this issue: #42004]

Due to the prependToMiddlewarePriority method in the Laravel Sanctum service provider, any middlewares added using the pushMiddlewareToGroup method in a package that is loaded before Sanctum, are removed from the group.

Steps To Reproduce:

  • Create a package that is loaded before Laravel Sanctum.
  • In the boot method of a service provider, in that package, use the pushMiddlewareToGroup function to add a middleware to the web group.
  • The middleware will not be applied, as it is removed from the group afterwards.

I can confirm that manually removing the line from the Sanctum service provider OR manually reordering the packages in the bootstrap file fixes the issue.

crotanite referenced this issue in lumite-studios/sanctum Jun 1, 2022
Due to an issue, Laravel will overwrite any middleware added using the `pushMiddlewareToGroup` method that are added in a service provider loaded before Sanctum. Removing this line, fixes the issue.

[https://github.com/laravel/framework/issues/42601](https://github.com/laravel/framework/issues/42601)
@driesvints
Copy link
Member

Unfortunately because the method in Sanctum is needed to make Sanctum work properly. Right now, we cannot account for third party packages manipulating this behavior. We would however, appreciate any PR to improve this and allow third party packages to integrate better while still allowing Sanctum to continue to work for existing apps.

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

No branches or pull requests

2 participants