gpt4 book ai didi

.net - Samesite cookie 和 Owin

转载 作者:行者123 更新时间:2023-12-03 20:56:46 28 4
gpt4 key购买 nike

为了兼容 Chrome 80- 版本,我们已经为 OWIN 应用程序实现了相同站点 Cookies 引用
https://docs.microsoft.com/en-us/aspnet/samesite/owin-samesite

我们有:

  • 升级到 4.1
  • 将 .net 框架定位到 .net 4.7.2

  • 它在 Chrome V 80 Beta 中运行良好。但是,在严格模式下 (.\chrome.exe --enable-features=SameSiteDefaultChecksMethodRigorously)。它给出了以下错误:

    Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolInvalidNonceException: IDX21323: RequireNonce is '[PII is hidden]'. OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce was not null. The nonce cannot be validated. If you don't need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to 'false'. Note if a 'nonce' is found it will be evaluated. at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator.ValidateNonce(OpenIdConnectProtocolValidationContext validationContext) at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator.ValidateAuthenticationResponse(OpenIdConnectProtocolValidationContext validationContext) at Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationHandler.d__9.MoveNext(



    有没有人遇到过这种情况?

    最佳答案

    可能是对这个问题的回复较晚,但迟到总比没有好:-)
    Chrome 已更新并进行了更改以减轻跨站点请求伪造 (CSRF),出于安全原因,这些更改将逐渐在所有浏览器上实现。
    [https://blog.chromium.org/2020/05/resuming-samesite-cookie-changes-in-july.html]
    下面的修复对我有用。

  • 在 webconfig.js 中添加以下代码

  • <!-- Add "SameSite=None" to any cookie which does NOT have it yet -->
    <!-- currently this only works for secure https cookies -->
    <rule name="Add SameSite">
    <conditions>
    <add input="{RESPONSE_Set_Cookie}" pattern="." />
    <add input="{RESPONSE_Set_Cookie}" pattern="; SameSite=None" negate="true" />
    <add input="{HTTPS}" pattern="on" ignoreCase="true" />
    </conditions>
    <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
    <action type="Rewrite" value="{R:0}; SameSite=None" />
    </rule>

    <!-Add "Secure" to any cookie which does NOT have it yet, as long as it's HTTPS request or else a secure cookie would just be ignored->
    <rule name="Add Secure">
    <conditions>
    <add input="{RESPONSE_Set_Cookie}" pattern="." />
    <add input="{RESPONSE_Set_Cookie}" pattern="; Secure" negate="true" />
    <add input="{HTTPS}" pattern="on" ignoreCase="true" />
    </conditions>
    <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
    <action type="Rewrite" value="{R:0}; Secure" />
    </rule>

    <!--If samesite was set to none by cookieSameSite="None",
    remove it for non-https requests (currently only works for https)-->
    <rule name="No SameSite For HTTP">
    <conditions>
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <match serverVariable="RESPONSE_Set_Cookie" pattern="(.);(\s)SameSite=None" />
    <action type="Rewrite" value="{R:1}" />
    </rule>
    </outboundRules>
    </rewrite>
  • 使用 [https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/1072]
  • 关于.net - Samesite cookie 和 Owin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60635388/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com