tuupola / slim-jwt-auth

PSR-7 and PSR-15 JWT Authentication Middleware
https://appelsiini.net/projects/slim-jwt-auth
MIT License
821 stars 140 forks source link

How to add a leeway? #229

Closed Dadinos closed 1 year ago

Dadinos commented 1 year ago

Is it possible to set the leeway value during the initialisation ?

Something like:


app->add(new \Tuupola\Middleware\JwtAuthentication([
    "path" => ["/api"],
    "attribute" => "decoded_token_data",
    "secret" => $jwt,
    "algorithm" => ["HS256"],
    "leeway" => 50,          <- something like this possible??
    "before" => function ($response, $arguments) {
  } ....

Or is there another way to do it?
tuupola commented 1 year ago

There is no support for leeway. Personally I think leeway is a bad fix when server clock is wrong. It would be better to fix the server clock instead for example by using NTP. I never had a need to use leeway myself.

Dadinos commented 1 year ago

Ok make sense, thanks