Laravel Passport 中的访问令牌被撤销刷新令牌
Refresh Token gets revoked with Access Token in Laravel Passport
我正在使用 laravel/passport password_grant
进行身份验证。整个生成 access_token
和 refresh_token
的过程运行良好。现在我正在尝试使用 laravel 护照令牌事件来撤销旧令牌。
我参考这个 post 的过程 -
https://laracasts.com/discuss/channels/laravel/laravel-passport-revoke-and-prune-event-listener-is-not-doing-anything
这行得通...但是当使用之前提供的 refresh token
刷新 access token
时,会创建一个新的 access token
并且还会创建一个新的 refresh token
创建。最终,在撤销旧 access token
的同时,未过期的旧 refresh token
也会被撤销。
但是我觉得,refresh token
一定要过期才能撤销
而且当我从 App\Providers\EventServiceProvider
$listen
数组 中删除 EventListeners
时,撤销机制仍然有效。
就像拔掉插头灯泡还亮着一样
如何解决这个问题?或者我在某个地方的概念有误?
But when refreshing an access token using the previously provided refresh token, a new access token is being created and also a new refresh token being is created.
这基本上就是使刷新令牌防止 MITM 攻击(在某种程度上)的原因。如果有人拦截了您的通信并找到了您的访问令牌,他们就可以在其存在期间一直冒充您。但是,如果他们拦截了您刷新令牌的请求,则只有你们中的一个人(用户和攻击者)可以使用它,因为它一旦使用就会被撤销。如果你先使用它,它对他们来说就没用了。如果他们先使用它,您将被注销,因为您的旧令牌将被撤销。如果他们可以拦截您的所有请求 - 并不断找到您的新访问令牌,您需要重新考虑您的安全设置。
来自 下的 RFC6749 部分 1.5. Refresh Token 图 2:刷新过期的访问令牌:
(H) The authorization server authenticates the client and validates
the refresh token, and if valid, issues a new access token (and,
optionally, a new refresh token).
我正在使用 laravel/passport password_grant
进行身份验证。整个生成 access_token
和 refresh_token
的过程运行良好。现在我正在尝试使用 laravel 护照令牌事件来撤销旧令牌。
我参考这个 post 的过程 - https://laracasts.com/discuss/channels/laravel/laravel-passport-revoke-and-prune-event-listener-is-not-doing-anything
这行得通...但是当使用之前提供的 refresh token
刷新 access token
时,会创建一个新的 access token
并且还会创建一个新的 refresh token
创建。最终,在撤销旧 access token
的同时,未过期的旧 refresh token
也会被撤销。
但是我觉得,refresh token
一定要过期才能撤销
而且当我从 App\Providers\EventServiceProvider
$listen
数组 中删除 EventListeners
时,撤销机制仍然有效。
就像拔掉插头灯泡还亮着一样
如何解决这个问题?或者我在某个地方的概念有误?
But when refreshing an access token using the previously provided refresh token, a new access token is being created and also a new refresh token being is created.
这基本上就是使刷新令牌防止 MITM 攻击(在某种程度上)的原因。如果有人拦截了您的通信并找到了您的访问令牌,他们就可以在其存在期间一直冒充您。但是,如果他们拦截了您刷新令牌的请求,则只有你们中的一个人(用户和攻击者)可以使用它,因为它一旦使用就会被撤销。如果你先使用它,它对他们来说就没用了。如果他们先使用它,您将被注销,因为您的旧令牌将被撤销。如果他们可以拦截您的所有请求 - 并不断找到您的新访问令牌,您需要重新考虑您的安全设置。
来自 下的 RFC6749 部分 1.5. Refresh Token 图 2:刷新过期的访问令牌:
(H) The authorization server authenticates the client and validates the refresh token, and if valid, issues a new access token (and, optionally, a new refresh token).