How to edit laravel passport token's expires_at field

一曲冷凌霜 提交于 2019-12-06 22:05:31

According to the docs, the default token lifetime should be set in your AuthServiceProvider.php by calling the Passport::tokensExpireIn() function in your boot() method.

Example:

public function boot() {
    ...

    $baseExpire = site_config('token_expires_minutes');

    Passport::tokensExpireIn(now()->addMinutes($baseExpire));
}

EDIT

Sorry, I misunderstood your original question. Unfortunately, it's not possible to change the expiration of a generated token, since the expiration is encoded into the actual token string (Laravel uses https://github.com/lcobucci/jwt to generate and validate tokens). However, you may look into overriding the passport validation to check the expiration on the table rather than using the default package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!