asp.net - 与 Azure AD 集成在 Azure IAAS 上托管的 .net 应用程序的相同站点问题
问题描述
我们拥有托管在 Azure IAAS 环境中的带有 Azure AD 集成的 ASP.NET Webforms 和 ASP.NET MVC 应用程序。由于最近的 Chrome 安全版本 > 80 及更高版本,大多数应用程序开始崩溃。请在下面找到框架版本
所有应用程序都在 4.5.2 上运行,并且还依赖于 NuGet 包
为了解决这个问题,我们探索了以下选项。由于我们有多个选项,因此我们需要专家就哪个选项最适合带有 Azure AD 集成的 APPS 提供意见。
在
system.webServer
标签下设置 IIS 重写规则。它无需任何代码更改和框架升级即可工作
<rewrite>
<outboundRules>
<preConditions>
<!-- Checks User Agent to identify browsers incompatible with SameSite=None -->
<preCondition name="IncompatibleWithSameSiteNone" logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="(CPU iPhone OS 12)|(iPad; CPU OS 12)" />
<add input="{HTTP_USER_AGENT}" pattern="(Chrome/5)|(Chrome/6)" />
<add input="{HTTP_USER_AGENT}" pattern="( OS X 10_14).*(Version/).*((Safari)|(KHTML, like Gecko)$)" />
</preCondition>
</preConditions>
<!-- Adds or changes SameSite to None for the session cookie -->
<!-- Note that secure header is also required by Chrome and should not be added here -->
<rule name="SessionCookieAddNoneHeader">
<match serverVariable="RESPONSE_Set-Cookie" pattern="(.*)(SameSite=.*)?" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="Rewrite" value="{R:1}; SameSite=None; Secure" />
</rule>
<!-- Removes SameSite=None header from all cookies, for most incompatible browsers -->
<rule name="CookieRemoveSameSiteNone" preCondition="IncompatibleWithSameSiteNone">
<match serverVariable="RESPONSE_Set-Cookie" pattern="(.*)(SameSite=.*)?" />
<action type="Rewrite" value="{R:1}" />
</rule>
</outboundRules>
</rewrite>
- 我们尝试将框架版本更新到 4.7.2 和相应的 nuget 包的另一个选项。它需要在 OpenIDconnect 上更改代码。我们尝试根据 Microsoft 提供的文档来实现相同的功能
- 第三是尝试将框架版本降级到 4.5.0 和相应的 NuGet 包。此选项也可以正常工作。
解决方案
推荐阅读
- generics - 为什么要格式化!当它是 AsRef 切片的第一个元素时产生错误?
- c++ - C++ 在不同的平台/架构上浮动和双打
- excel - 如何解决 VBA Excel 中的运行时错误?
- ssh - 如何使用 JSCH 在另一个命令的终端内在 linux 中执行命令
- node.js - 勾选带有 nodejs 发布请求的单选按钮
- typescript - 如何用 jest 测试“npm run my-custom-cmd”?
- django-models - DRF 序列化程序获取/发布/删除工作但“放置”失败
- java - Spring Boot 从模板写入 CSV
- python - Django Python - 使用预填充表单创建登录页面
- string - 为什么 cut 不适用于程序的输出?