久久久久久久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)標頭)
主站蜘蛛池模板: 天堂国产| 免费观看一级特黄欧美大片 | 国产欧美日韩综合精品一 | 久久成人人人人精品欧 | 国产精品18hdxxxⅹ在线 | 天天看逼 | 久久综合伊人一区二区三 | 日本精品国产 | 亚洲国产精品99久久久久久久久 | 欧美一级片 | 日韩高清一区二区 | 久久另类 | 国产精品揄拍一区二区久久国内亚洲精 | 亚洲www| 国产高清一区二区三区 | 国产成人99久久亚洲综合精品 | 精品国产乱码久久久久久蜜柚 | 在线观看av网站 | 久久蜜桃av | 久久久精选 | 羞羞的视频免费在线观看 | 国产精品久久久久久av公交车 | 999精品视频 | 国产在线资源 | 青娱乐国产 | 日韩欧美在线免费观看视频 | 91av久久久| 欧美a级成人淫片免费看 | 99pao成人国产永久免费视频 | 久久视频精品 | 国产免费av网 | 在线观看亚洲专区 | 久久亚洲一区二区 | 日韩欧美三区 | 男女在线免费观看 | 国产激情视频在线免费观看 | 日韩a在线观看 | 91精品久久久久久久久 | 一级黄色夫妻生活 | cao在线| 色综久久 |