gpt4 book ai didi

通过 cookie 进行 Laravel Passport 身份验证 - 注销时过期?

转载 作者:行者123 更新时间:2023-12-03 17:36:01 25 4
gpt4 key购买 nike

在我的项目中,我正在集成 Laravel Passport 以便在我的应用程序中使用我的 API,如 here 所述。 .

我的问题是关于 laravel_token 的有效期曲奇饼。可以看出here ,我的应用程序发回的 cookie 被检查以验证它没有过期。这个过期时间似乎是由我的 session 生命周期定义的 - 见 here .

这似乎意味着 laravel_token cookie 将在我的应用程序的用户注销后仍然有效,只要 session 时间没有过期(实际上,如果我删除服务器上的所有 session 并且注销我的用户,使用 cookie 的 API 请求仍然成功)。

这是预期的行为吗?如果用户注销,是否有办法自动使 cookie 过期? (我知道 cookie 已从用户的系统中删除,但我是从 cookie 被劫持或被盗的理论可能性来看它的,然后只要 session 生命周期没有过期就可以使用)。

最佳答案

试试这种方式,在这种情况下,refresh_tokens 被禁用,cookies 也会丢失。

    $accessToken = Auth::user()->token();
DB::table('oauth_refresh_tokens')
->where('access_token_id', $accessToken->id)
->update(['revoked' => true]);
$accessToken->revoke();

\Cookie::queue(\Cookie::forget(Passport::cookie()));

关于通过 cookie 进行 Laravel Passport 身份验证 - 注销时过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48091756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com