3

我已阅读 NWebSec 的文档以尝试解决问题。

设置web.config

  <nwebsec>
<httpHeaderSecurityModule
  xsi:noNamespaceSchemaLocation="NWebsecConfig/HttpHeaderSecurityModuleConfig.xsd"
  xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<redirectValidation enabled="false">
  <allowSameHostRedirectsToHttps enabled="false"/>
  <add allowedDestination="https://www.facebook.com/"/>
  <add allowedDestination="http://www.nwebsec.com/"/>
  <add allowedDestination="https://www.google.com/accounts/"/>
</redirectValidation>
  <securityHttpHeaders>
    <strict-Transport-Security max-age="365" includeSubdomains="true" httpsOnly="false" preload="true" />
  </securityHttpHeaders>
</httpHeaderSecurityModule>

但我仍然得到

检测到潜在危险的重定向。如果打算进行重定向,请将目标添加到配置中的白名单中。违规重定向:https ://www.facebook.com/dialog/oauth?response_type=code&

4

1 回答 1

0

这在答案之前出现在谷歌中,这里是:https ://docs.nwebsec.com/en/latest/nwebsec/Redirect-validation.html

总之,您必须将登录服务引用的 URL 列入白名单,如下所示:

   app.UseRedirectValidation(opts =>
        {
            opts.AllowedDestinations( "https://www.facebook.com/dialog/oauth");
            opts.AllowedDestinations("https://login.microsoftonline.com"); // Tested
        });
于 2019-09-20T11:38:01.763 回答