-
-
Notifications
You must be signed in to change notification settings - Fork 282
Auth check return false in middleware, but should return true with Log Viewer #428
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
Comments
I experienced the same issue. I just updated logviewer to 3.15. (I am using Laravel 9) and after the composer upgrade, I received a 403 error. I downgraded back to 3.1.5 and the issue was gone. For some strange reason, the permission error only happens in production, not locally. I also tried to remove my custom middleware, but still got a 403. |
i note that the "XSRF-TOKEN" mismatch when i check the api request. Some can give a clue ? |
Hey @zekuraz , is there any reason you cannot utilise Log Viewer's callbacks as written in the documentation? For example, you could just add this to your AppServiceProvider: public function boot()
{
LogViewer::auth(function ($request) {
// Always allow access locally
if (App::environment('local')) {
return true;
}
// Otherwise, check for the "admin" role.
return Auth::check() && Auth::user()->hasRole('admin');
});
} |
Hi @arukompas , I also try add this to my AppServiceProvider, but it always returns to me false. |
@zekuraz After installing this in a bunch of different applications the most common reason I've found for this is that your APP_URL (in .env) or config('app.url') needs to be the exact domain you are using. Eg: APP_URL=http://local.my-domain.com ... or of course whatever you are serving your site locally as. Note that it says in the docs/config that if the log viewer config key 'log-viewer.route_domain' is set to null it should work on all domains but I've found that this isn't true. |
Hi !
I installed Log Viewer in my laravel 11 protect, and works like a charm. But i want to limit who has access to the Log Viewer in production.
So,i create a middleware
Add the following to $middlewareAliases array In app\Http\Kernel.php
And add middleware to the the log viewer config
If i try to debug Auth::check(), it's always return false.
I also try Auth::guard('api'), it's doesn't work.
For information, i use Laravel Passport in my project.
Thanks in advance for your help !
The text was updated successfully, but these errors were encountered: