robsontenorio / laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel
MIT License
434 stars 141 forks source link

TokenExpired Exception not catchable by middleware #40

Closed ceelsoin closed 3 years ago

ceelsoin commented 3 years ago

Hi, i have a trouble with Token Expired Exception. the vendor/robsontenorio/laravel-keycloak-guard/src/KeycloakGuard.php call a $this-autenticate() on class construction, and if a token was expired launch a catch block on line 41 casting a new TokenException($e->getMessage());

The problem are on my middleware for autenticate. He not catch a any exception of expired token, this cause a problem can not be a json response, returning a 500 status and laravel html message instead of json

robsontenorio commented 3 years ago

In someway your app must be preppared to verify token expiration time, before make new requests. So you can prevent that error in advance.

But if you don't so. A option would be the Laravel global error handling

https://laravel.com/docs/8.x/errors#introduction

All errors thrown by packages are excpected. So, that issue would be out of scope of this package.