似乎找不到任何使 FusionAuth 在注销时向应用程序发送信号以终止用户会话的东西。
问问题
349 次
1 回答
1
FusionAuth 提供了一个/api/logout
可能会起作用的 API。此 API 将撤销用户拥有的任何刷新令牌。当刷新令牌被撤销时,FusionAuth 将向任何已配置的 Webhook 发送一个事件。
以下是有关此 API、Webhooks 和触发事件的文档:
- https://fusionauth.io/docs/v1/tech/apis/login#logout-a-user
- https://fusionauth.io/docs/v1/tech/events-webhooks/events#jwt-refresh-token-revoke
- https://fusionauth.io/docs/v1/tech/events-webhooks/writing-a-webhook
以下是您可以采取的粗略步骤来完成这项工作:
- 在您的应用程序或新的微服务中创建注销端点 (
https://example.com/global-logout
) - 该端点调用
/api/logout
FusionAuth中的端点 - 每个想要被通知的应用程序然后编写一个 Webhook 并处理
jwt.refresh-token.revoke
事件
您可以在有关文档的链接中看到一个示例 Webhook。处理事件的 Webhookjwt.refresh-token.revoke
在 Node/JavaScript 中可能如下所示:
router.route('/fusionauth-webhook').post((req, res) => {
const request = req.body;
if (request.event.type === 'jwt.refresh-token.revoke') {
// Clean up all the user's stuff here
}
});
于 2019-07-30T18:44:21.617 回答