gpt4 book ai didi

.net - 保护 Azure 上的 .NET Core API - 仍然接受设置了 RequireHttpsAttribute 的 HTTP

转载 作者:行者123 更新时间:2023-12-03 04:27:07 25 4
gpt4 key购买 nike

我使用 POSTMAN ( https://www.getpostman.com/ ) 来测试部署到 Azure 的 API(使用 *.azurewebsites.net SSL 证书)。该 API 是标准 MVC .NET Core API。

基于 Pluralsight 教程 ( https://www.pluralsight.com/courses/aspdotnetcore-implementing-securing-api ),我按照所述在startup.cs 中添加了 RequireHttpsAttribute 选项。

services.AddMvc( opt => opt.Filters.Add(new RequireHttpsAttribute()) )

但是,当使用来自 POSTMAN 的 HTTP(而不是 HTTPS)时,我仍然收到响应数据。

有什么想法我可能在这里做错了吗?

谢谢。

最佳答案

您是否托管在应用服务中?如果是这样,则前端之外没有 HTTPS。

检查是否存在 X-ARR-SSL header 。
看到这个:https://stackoverflow.com/a/38726543/4148708

关于.net - 保护 Azure 上的 .NET Core API - 仍然接受设置了 RequireHttpsAttribute 的 HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41912790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com