【问题标题】:Using authorization.json with Azure Functions breaks portal将 authorization.json 与 Azure Functions 结合使用会破坏门户
【发布时间】:2019-01-31 14:39:27
【问题描述】:

我正在使用 Azure Functions,并且正在使用 AAD 进行身份验证。但是,我有一个使用 EventGrid 触发器的函数,因此我需要禁用该函数的身份验证。为了实现这一点,我在函数应用程序中设置了身份验证设置以允许匿名请求,并且我正在使用一个 authorization.json 文件来为所有函数打开身份验证,除了我想要匿名的函数。

如果我使用这样的授权.json 文件,那么当我进入门户并单击其中一个函数时,我会收到一条错误消息,指出函数运行时无法启动:

{
  "routes": [
    {
      "path_prefix": "/",
      "policies": { "unauthenticated_action": "RejectWith401" }
    },
    {
      "path_prefix": "/runtime/webhooks/EventGrid",
      "policies": { "unauthenticated_action": "AllowAnonymous" }
    }
  ]
}

但是,如果我像这样更改它,门户将再次运行,但我假设管理端点现在将全部打开。

{
  "routes": [
    {
      "path_prefix": "/",
      "policies": { "unauthenticated_action": "RejectWith401" }
    },
    {
      "path_prefix": "/runtime/webhooks/EventGrid",
      "policies": { "unauthenticated_action": "AllowAnonymous" }
    },
    {
      "path_prefix": "/admin",
      "policies": { "unauthenticated_action": "AllowAnonymous" }
    }
  ]
}

我应该如何配置我的 authentication.json 文件,以确保除 EventGrid 功能之外的所有内容都是安全的?

【问题讨论】:

    标签: azure authentication azure-functions


    【解决方案1】:

    我正在使用以下内容并且它有效。

    {
      "routes": [
        {
          "path_prefix": "/api",
          "policies": { "unauthenticated_action": "RejectWith401" }
        },
        {
          "path_prefix": "/runtime/webhooks/EventGrid",
          "policies": { "unauthenticated_action": "AllowAnonymous" }
        }
      ]
    }
    

    在根“/”修复门户上没有条目。

    即使没有指定 /admin,/admin url 也受到保护。我尝试通过浏览器访问它,它返回未经授权的 401。

    【讨论】:

      猜你喜欢
      • 2021-11-03
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多