gpt4 book ai didi

jwt - 如果用户想从不同的机器上退出帐户,JSON Web token (JWT) 是否会被拒绝或列入黑名单?

转载 作者:行者123 更新时间:2023-12-04 18:37:12 26 4
gpt4 key购买 nike

我正在构建一个需要身份验证的应用程序,我担心用户可能希望能够远程注销。有没有办法使用 JSON Web token 并能够将它们列入黑名单或拒绝它们?我知道他们的好处是无国籍,但是远程注销会很好。

编辑:Express.js 使用 express-jwt 模块,有一个 method to revoke tokens .此外,还有一个模块 express-jwt-blacklist .我仍然不明白这些策略是如何工作的,并且想知道此时的最佳实践是什么。

最佳答案

关于 Auth0 有一篇不错的文章
Blacklisting JSON Web Token API Keys他们在其中给出了一个很好的真实示例,说明如何将 JWT API key 列入黑名单,使其不再有效。你应该读一读。

Framing the problem

Providing support for blacklisting JWTs poses the following questions:

  1. How are JWTs individually identified?
  2. Who should be able to revoke JWTs?
  3. How are tokens revoked?
  4. How do we avoid adding overhead?

This blog post aims to answer the previous questions by leveraging our experience from implementing this feature in our API v2.



这篇文章分解了每一点,然后展示了一些关于如何实现它的示例代码,最后是:

Most of the aforementioned content applies to blacklisting JWTs in general, not just JWT API keys.

Hopefully this blog post has provided some useful ideas on how to tackle this problem.



我个人应用了类似的方法来撤销多个登录,其中 token 的使用与 session ID 类似并存储在 cookie 中。我将其建模为 GitHub 配置文件部分,用户可以在其中查看所有其他事件 session 并在需要时撤销它们(远程注销)。

就最佳实践而言,我认为该主题将基于意见。但是,我确实将 Auth0 视为该 Topis 领域良好实践的来源,有很多人在这方面经验丰富。

更新:

找到这个 express-jwt plugin for token blacklisting在 npm 上

关于jwt - 如果用户想从不同的机器上退出帐户,JSON Web token (JWT) 是否会被拒绝或列入黑名单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36513876/

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