ASP.Net Core 为我的应用程序制作了太多 cookie 无法处理 [英] ASP.Net Core makes too many cookies for my app to handle

查看:29
本文介绍了ASP.Net Core 为我的应用程序制作了太多 cookie 无法处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试应用程序,用于测试与我的 WSO2 身份服务器 IDP 的集成.当它自己运行时,它工作得很好.它生成一个 .AspNetCore.Antiforgery cookie 和一个 .AspNetCore.Cookies cookie.防伪cookie为190字节,主cookie为3.7K字节.

I have a test application that I am using to test integration with my WSO2 Identity Server IDP. When run by itself it works just fine. It makes an .AspNetCore.Antiforgery cookie and an .AspNetCore.Cookies cookie. The anti-forgery cookie is 190 bytes and the main cookie is 3.7K bytes.

但是如果我先登录到另一个应用程序,然后加载我的测试工具页面,它会获得 4 个额外的 cookie:

But if I login to another application first, then load my my test harness page, it get 4 additional cookies:

  • .AspNetCore.CookiesC1 - 4K 字节
  • .AspNetCore.CookiesC2 - 4K 字节
  • .AspNetCore.CookiesC3 - 4K 字节
  • .AspNetCore.CookiesC4 - 1K 字节
  • .AspNetCore.CookiesC1 - 4K Bytes
  • .AspNetCore.CookiesC2 - 4K Bytes
  • .AspNetCore.CookiesC3 - 4K Bytes
  • .AspNetCore.CookiesC4 - 1K Bytes

这些额外的 cookie 使我超出了某种限制,因为页面加载时出现以下错误(而不是我的应用程序):

These additional cookies put me over a limit of some kind, because a page loads with the following error (instead of my application):

错误请求 - 请求太长
HTTP 错误 400.请求头的大小太长.

Bad Request - Request Too Long
HTTP Error 400. The size of the request headers is too long.

我不知道如何查看这些附加 cookie 中的内容,因为它们是 base 64(而且我认为它们是加密的).

I don't know how to see what is in these additional cookies because they are base 64 (and I think they are encrypted).

我的问题是,为什么 ASP.Net 核心会因为我登录到另一个站点(使用相同的 WSO2 IDP,但使用不同的 OIDC 应用程序)而添加这么多额外的 cookie?我可以防止它发生吗?

My question is, why would ASP.Net core add so many extra cookies just because I logged into another site (using the same WSO2 IDP, but a different OIDC application)? And can I prevent it from happening?

附加说明:

  • 当我一遍又一遍地复制它以获取详细信息时,我注意到有时它可以添加额外的 cookie,但不会给出错误消息.当这种情况发生时,唯一的区别似乎是 .AspNetCore.Cookies 的原始 cookie 被更改为读取4 个块"而不是它的长期价值.但这仅适用于第二个应用程序.另一个似乎能够用额外的尺寸加载它(我已经尝试颠倒顺序......)我很困惑......
  • As I reproduce this over and over to get details, I am noticing that sometimes it can add the extra cookies, but not give the error message. When that happens, the only difference seems to be that the original cookie of .AspNetCore.Cookies is changed to read "4 chunks" instead of its long value. But this is only on the second application. The other seems to be able to load it fine with the extra size (and I have tried reversing the order...) I am very confused...

推荐答案

当您的用户身份声明过多时,通常会发生这种情况.您可能会尝试修改您的应用程序,使其仅保留有关您的用户的最常用信息在声明中,并按需查找其他信息.

This often happens when you have too many claims in your user identity. What you might try doing is modifying your application so that it only keeps the most commonly used information about your user in claims and does an on-demand lookup for the others.

这篇关于ASP.Net Core 为我的应用程序制作了太多 cookie 无法处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆