【问题标题】:How to inject cookies in the Authorization header when they are store in httpOnly当 cookie 存储在 httpOnly 中时,如何在 Authorization 标头中注入 cookie
【发布时间】:2023-01-31 02:36:52
【问题描述】:

我以这种方式(服务器端)将我的令牌存储在 cookie 中:

res.cookie('access_token', token. access_token, { httpOnly: true });

因此,在客户端,我无法将其注入授权标头,因为它们存储在 httpOnly 中,有人有问题吗?或者我需要在服务器端手动提取令牌以将其放入标头中?

【问题讨论】:

    标签: vue.js cookies jwt nestjs token


    【解决方案1】:

    您无法从 JavaScript 访问 HttpOnly 令牌,这是该属性的用途。

    更好的方法是完全不在浏览器中处理令牌,而是使用 BFF 模式 (Backends for Frontends),如本视频中所述:

    alert‘OAuth 2 0’; // The impact of XSS on OAuth 2 0 in SPAs

    【讨论】:

      猜你喜欢
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 2019-11-05
      • 2020-05-05
      • 1970-01-01
      • 2020-12-12
      • 2021-05-18
      • 2021-02-11
      相关资源
      最近更新 更多