久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

sessionStorage 與 cookie 中的 JWT 令牌?

JWT tokens in sessionStorage vs cookies?(sessionStorage 與 cookie 中的 JWT 令牌?)
本文介紹了sessionStorage 與 cookie 中的 JWT 令牌?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

Stormpath 有很多博客文章討論應(yīng)該如何使用 cookie 來存儲 JWT,而不是 sessionStorage/localStorage:

There are a lot of blog posts from Stormpath that talk about how you ought to use cookies to store your JWT instead of sessionStorage/localStorage:

  • https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage
  • https://stormpath.com/blog/token-auth-spa
  • https://stormpath.com/blog/build-secure-用戶界面使用 jwts

主要原因是,如果您加載的第 3 方 javascript 依賴項受到損害,它可以通過 sessionStorage/localStorage 竊取并將 JWT 傳輸?shù)侥硞€地方.

The main stated reason is that if a 3rd-party javascript dependency that you load is compromised that it can pilfer through sessionStorage/localStorage and transmit off the JWT to somewhere.

但這對我來說是一個令人困惑的原因.我了解攻擊向量,但如果您有一個受損的 3rd-party javascript 依賴項,那么您是不是真的搞砸了,因為它可以監(jiān)聽/捕獲您的用戶在與您的應(yīng)用程序交互時所做的任何事情?

But this is confusing as a reason to me. I understand the attack vector, but if you have a compromised 3rd-party javascript dependency, aren't you effectively screwed anyway, since it can listen-in/capture anything your users do as they interact with your app?

推薦答案

我是https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage

當頁面上存在 XSS 時,攻擊者有權(quán):

When XSS exist on a page, an attacker is privileged to:

  • HTML5 網(wǎng)絡(luò)存儲(本地和會話)
  • 未設(shè)置 httpOnly 標志的 Cookies
  • 控制標簽直到它被關(guān)閉并且能夠提出未經(jīng)授權(quán)的請求

您還可以開始制定攻擊以繞過 XSRF 保護.

You can also start to formulate attacks to get around XSRF protection.

當存在 XSRF 漏洞時,攻擊者有權(quán):

When an XSRF vulnerability exists, an attacker is privileged to:

  • 從第三方域發(fā)出未經(jīng)授權(quán)的請求,前提是您可以將用戶引誘到那里(或在存在 XSS 的情況下將其發(fā)送到那里).

您可以看到,當存在 XSS 漏洞時,您可以發(fā)出未經(jīng)授權(quán)的請求,攻擊者需要跳過更多的障礙來利用 XSRF.這意味著當 XSS 存在時(無論是否有 XSRF 保護),都會存在發(fā)出未授權(quán)請求的攻擊向量.

You can see that when an XSS vulnerability exists, you are able to make unauthorized requests and an attacker would need to jump through some more hoops to exploit XSRF. This means that when XSS exists (regardless of XSRF protection or not), the attack vector of making unauthorized requests will exist.

希望這可以為我的下一點解決問題.

Hopefully, that clears things up for my next point.

與竊取代表用戶身份和會話的無狀態(tài)令牌相比,XSRF 攻擊或未經(jīng)授權(quán)的請求的影響和范圍更小.泄露令牌意味著攻擊者將擁有完全控制權(quán),可以代表用戶在他的時間、在他的機器上制定攻擊.

An XSRF attacks or unauthorized requests has less impact and scope than stealing a stateless token that represents the user's identity and session. Leaking the token means that an attacker will have full control to formulate an attack on behalf of the user, on his time, on his machines.

總之,當你存在 XSS 時:

In conclusion, in presence of XSS when you:

  • 在網(wǎng)絡(luò)存儲中存儲訪問令牌,在 XSS 存在期間使用您網(wǎng)站的任何用戶的令牌都會受到損害.這意味著攻擊者可以獲得數(shù)以千計的有效訪問令牌,并可能造成很多傷害(如果您將刷新令牌存儲在 Web 存儲中,則危害更大).用戶也容易從自己的瀏覽器發(fā)出未經(jīng)授權(quán)的請求.

  • store an access token in web storage, the tokens for any user that uses your site during the time of the existence of XSS is compromised. This means an attacker could get thousands of valid access tokens and can possibly do a lot of harm (even more if you store refresh tokens in web storage). The users are also vulnerable to making unauthorized requests from their own browser.

將訪問令牌存儲在 httpOnly cookie 中,任何用戶的令牌都不會被泄露.但是,即使存在 XSRF 保護,用戶也容易從自己的瀏覽器發(fā)出未經(jīng)授權(quán)的請求.

store an access token in a httpOnly cookie, the tokens for any user are not compromised. But, the users are also vulnerable to making unauthorized requests from their own browser even in the presence of XSRF protection.

希望這些信息對您有所幫助.

Hope this information helps.

這篇關(guān)于sessionStorage 與 cookie 中的 JWT 令牌?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is Math.random() cryptographically secure?(Math.random() 在密碼學上是安全的嗎?)
Secure random numbers in javascript?(在javascript中保護隨機數(shù)?)
How to avoid multiple token refresh requests when making simultaneous API requests with an expired token(使用過期令牌發(fā)出同時 API 請求時如何避免多個令牌刷新請求)
JWT not decoding quot;JWT malformedquot; - Node Angular(JWT 未解碼“JWT malformed;- 節(jié)點角度)
How to invalidate a JWT token with no expiry time(如何使沒有到期時間的 JWT 令牌無效)
Authorization header in img src link(img src 鏈接中的授權(quán)標頭)
主站蜘蛛池模板: 日韩欧美专区 | 日韩2020狼一二三 | 国产亚洲欧美在线视频 | 国产精品一区二区av | 欧美极品视频 | 东方伊人免费在线观看 | 欧美在线一区二区三区 | 岛国av免费观看 | 涩涩视频在线观看免费 | 亚洲午夜精品一区二区三区他趣 | 欧美亚洲国产一区二区三区 | 一区二区三区在线 | 毛片一区二区三区 | 久久这里只有精品首页 | 午夜影视免费片在线观看 | 色橹橹欧美在线观看视频高清 | 国产黄色在线观看 | 在线观看免费av网 | 亚洲精品一区二区三区丝袜 | 精品久久久久久18免费网站 | 国产高清一区二区三区 | 欧美日韩1区2区 | 国产精品福利视频 | 成人免费在线视频 | 精精久久 | 日日拍夜夜 | 国产黄色av电影 | 日韩av免费在线观看 | 亚洲一区久久久 | 欧美视频在线看 | 国产 日韩 欧美 在线 | 91福利网| 一区二区三区亚洲 | 成人国产精品久久久 | 久久久久亚洲精品 | 天天射天天干 | 亚洲最大av | 日本午夜免费福利视频 | 欧美综合网 | 欧美极品视频在线观看 | 97伦理电影 |