Closed thomas2312 closed 3 years ago
Hi. Would you please try to run php artisan route:clear
?
It is not possible to do run php artisan route:clear
, because I also get this Exception:
Symfony\Component\Routing\Exception\RouteNotFoundException
Route [keycloak.callback] not defined.
at C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php:429
I can run the command, but I have to remove the following code from the AuthServiceProvider.php before:
if (Gate::denies('keycloak-web', 'auth')) {
return abort(403);
}
But that was not the solution of my problem.
I was not able to reproduce the problem. I have two routes to check just login and to check Gate in my example environment and everything is OK.
You are not required to use Gate to make sure a URL is private. Indeed you should use gate to check the user has a specific role. In your case, are you trying to check the user has the 'auth' role in Keycloak?
After 5 minutes:
Now I figured you are using Gate in boot method. Why? I guess it's too early.
Yes, a login should be only possible, if the user has the 'auth' role. I want to do this check as soon as possible.
Please. Try to do this in controller layer.
Thank you. I solved it with a custom Middleware.
Hi.
I have the following Probem: I am trying to use the Laravel Authorization Gate in the boot method of the AuthServiceProvider.php
If I try to access the page, I always get "Route [keycloak.callback] not defined.".
The following routes are defined in the the web.php:
Can you tell me, why the route is not definied?