如何强制dotnet核心JWT身份验证以不存储键

发布于 2025-01-31 09:28:36 字数 464 浏览 2 评论 0原文

强文 内存转储的堆屏幕截图我已经实现了dotnet core jwt在我的dotnet core API中进行身份验证,当我启动应用程序时,生成的密钥文件在./appdata/local/asp.net/dataprotection-keys路径中。我知道这是dotnet core使用的DataProtection键来保护数据和dotnet core(默认情况下)从该位置和存储器中键的高速缓存中读取,但问题是,在该文件夹和dotnet中生成了许多键。默认情况下,核心每24小时阅读此信息,并相应地更新缓存。由于钥匙的大量钥匙,我在垃圾收集的一部分中遇到了MEMMORY泄漏问题。是否必须存储该钥匙?无论如何,我们可以通过编程删除过期的键吗?

任何帮助。

提前致谢。

strong textHeap Screenshot of memory dumpI have implemented dotnet core jwt authentication in my dotnet core api and when I start my app a key file generated in ./AppData/Local/ASP.NET/DataProtection-Keys path. I came to know that it is dataprotection key used by dotnet core to protect data and dotnet core by default read from that location and cache that keys in memory but the issue is that in production environment by time many keys are generated in that folder and dotnet core by default read this every 24 hrs and update cache accordingly. Due to huge amount of keys I am getting memmory leakage issue in LargObject portion of Garbage collection. Is is mandatory to store that keys? Is there anyway we can remove expired keys programatically?

Any help appriciated.

Thanks in Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

身边 2025-02-07 09:28:37

您可以提供自己的加密密钥,如果这样做,那么ASP.NET Core就不需要创建任何数据保护密钥。

拥有密钥很重要,因为该键用于加密和解密ASP.NET核心会话cookie。

我在这里进行了有关数据保护的博客,这些数据可能会对您有所帮助:
存储ASP.NET核心数据保护键环在Azure键值库中

但是,数据保护API不应导致任何内存泄漏。

You can provide your own encryption key, and if you do that then ASP.NET Core does not need to create any data protection keys.

Having a key is important, because that key is used to encrypt and decrypt the ASP.NET Core session cookie.

I did blog about the data protection here that might help you:
Storing the ASP.NET Core Data Protection Key Ring in Azure Key Vault

However, the data protection API should not cause any memory leaks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文