c# - 联合身份 token 复制字符以关闭标签(cookie)(使用 Thinktecture Identity Server)

标签 c# asp.net-mvc cookies thinktecture-ident-server ws-federation

正在设置的 cookie 遇到一个奇怪的问题。大多数情况下,一切都按预期工作,但有时我会收到错误

System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. 
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at System.IdentityModel.Services.ChunkedCookieHandler.ReadInternal(String name, HttpCookieCollection requestCookies)
at System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken)
at System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

我可以一遍又一遍地执行相同的步骤,此错误将随机显示。也许在 5 日去然后 10 日去下一次。

当我查看浏览器中的 cookie 时,我可以看到错误发生时结束标记的最后几个字符被重复。 Cookie如下(重要位),

FedAuth={base64string}
FedAuth1={base64string}cml0eUNvbnRleHRUb2tlbj4=
FedAuth2=b2tlbj4=

注意 FedAuth1 如何以 FedAuth2 的字符结束。由于某种原因,这个 FedAuth2 cookie 被不必要地创建并导致字符串以

结尾
</SecurityContextToken>oken>

(base64 解密)。

我很迷茫...

最佳答案

我仍然不确定为什么会发生这种情况,但我设法通过重命名我的一些角色来解决问题,这样 cookie 就不会超过 2 个 FedAuth cookie。问题似乎出在创建的第三个 cookie 上。

关于c# - 联合身份 token 复制字符以关闭标签(cookie)(使用 Thinktecture Identity Server),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26837147/

相关文章:

c# - C# 中的 SOAP 请求

asp.net-mvc - 如何在 log4net 中将 LogLevel 设置为错误以应对hangfire

asp.net-mvc - 为什么一个 MVC 应用程序中有这么多接口(interface)

c# - 从 Controller 返回局部 View ?

python - 如何使用 python (requests/urllib3) 登录 facebook?

c# - 如何使用 Asp.net 设置 .asmx web 服务启用跨源

c# - 将变量传递给 catch block

javascript - Angular Translate - 获取翻译表

javascript - 使用 JS 检测 IE 11 中是否启用 Cookie

c# - 在设计应用程序时如何使用 Func<> 和 Action<>?