【问题标题】:How to enforce only Https only request to identityserver4如何仅对identityserver4执行仅Https请求
【发布时间】:2018-12-18 15:12:29
【问题描述】:

我在 Azure 应用服务上配置和部署了 IdentityServer4,我使用了自定义 SSL 证书来签署令牌。一切正常,但是我想强制身份服务器仅接收来自 https 客户端的请求,否则抛出错误。

我在 identityserver4(http://docs.identityserver.io/en/latest/topics/crypto.html?highlight=HTTPS) 上阅读了这部分文档,他们说: "我们不强制使用 HTTPS,但对于生产来说,与 IdentityServer 的每次交互都是强制性的。"

只是想知道是否可以仅强制执行 https 客户端请求。

非常感谢任何帮助或指点

【问题讨论】:

    标签: identityserver4


    【解决方案1】:

    这通常是您在 Web 服务器/流量管理器级别而不是在应用程序级别配置的东西(尽管您当然也可以使用应用程序逻辑来强制执行它)。

    这应该有用:https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-ssl

    还可以查看 HSTS 标头:https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet

    还可以考虑使用强大的内容安全策略来阻止或升级不安全的资源请求。例如Content-Security-Policy: upgrade-insecure-requests; block-all-mixed-content;查看https://report-uri.com/home/generatehttps://scotthelme.co.uk/csp-cheat-sheet/

    【讨论】:

      【解决方案2】:

      您可以通过 Startup 类的 Configure 方法中的以下调用来强制执行 HSTS 标头和 HTTPS 重定向。

      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
       //...
       app.UseHsts();
       app.UseHttpsRedirection();
       //...
      }
      

      有关所有配置选项和最佳实践,请参阅此链接: https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-30
        • 1970-01-01
        • 2015-09-05
        • 2014-10-10
        • 2016-08-30
        • 1970-01-01
        相关资源
        最近更新 更多