代码之家  ›  专栏  ›  技术社区  ›  sampa

使用ADFS阻止匿名文件夹访问

  •  0
  • sampa  · 技术社区  · 6 年前

    防止未经授权访问这些文件夹(例如/捆绑包)的最佳方法是什么?

    是否可以在web.config文件或者是IIS配置?

    0 回复  |  直到 6 年前
        1
  •  0
  •   Brando Zhang    6 年前

    根据您的描述,我建议您尝试设置特殊文件夹的身份验证设置。此设置将仅适用于该文件夹。然后我们可以禁用该文件夹的匿名身份验证。

    更多详情,请参考以下步骤:

    1.打开IIS管理控制台并选择文件夹。

    enter image description here

    enter image description here

        2
  •  0
  •   user1565840    5 年前

    如果使用OWIN中间件配置ADFS身份验证,则可以使用以下代码保护所有匿名请求:

    app.Use((context, cont) =>
                {
                    if ((context.Authentication.User != null) && (context.Authentication.User.Identity != null) && (context.Authentication.User.Identity.IsAuthenticated))
                    {
                        return cont();
                    }
                    else
                    {
                        var provider = "ADFS Server";
                        context.Authentication.Challenge(new AuthenticationProperties
                        {
                            RedirectUri = "https://youapp-url/"
                        }, provider);
                        return Task.Delay(0);
                    }
                });