我已在Azure App Service上配置并部署了IdentityServer4,已使用自定义SSL证书对令牌进行签名。一切正常,但是我想强制身份服务器仅接收来自https客户端的请求,否则抛出错误。
我阅读了有关identityserver4(http://docs.identityserver.io/en/latest/topics/crypto.html?highlight=HTTPS)的文档的这一部分,他们说: “ 我们不强制使用HTTPS,但是对于生产而言,与IdentityServer的每次交互都是必不可少的。”
我只是想知道是否可以仅执行https客户端请求。
非常感谢任何帮助或指针
答案 0 :(得分:0)
通常这是您在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/generate和https://scotthelme.co.uk/csp-cheat-sheet/
答案 1 :(得分:0)
您可以在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