Azure Web 应用程序 + Node.js + Azure AD = 错误 431 [英] Azure Web App + Node.js + Azure AD = Error 431

查看:30
本文介绍了Azure Web 应用程序 + Node.js + Azure AD = 错误 431的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于 Node.js 的 Web 应用程序,在 Azure Web 应用程序中运行,我想将其置于 Azure Active Directory 身份验证之后.激活应用服务身份验证"后,登录过程正常,但是返回我的应用后,它只返回一个 HTTP 431请求标头字段太大".

I created a Node.js based web application, running in an Azure Web App, that I wanted to put behind an Azure Active Directory authentication. After activating "App Service Authentication", the login process works normally, however upon returning to my app, it just returns a HTTP 431 "Request Header Fields Too Large".

为了验证它不是我的应用程序,我检查了 Node.js 的 Azure Web 应用程序示例,甚至在激活 AAD 时返回 431.

To validate it's not my app, I checked the Azure web app sample for Node.js and even this returns a 431 when activating AAD.

重现步骤:

  • 创建新的 Azure 资源 -> Web 应用
    • 选择任何基于 Node 的运行时堆栈,例如 Node 12 LTS
    • 选择任何操作系统
    • 创建网络应用并等待部署完成
    • 将应用服务身份验证"设置为开启"
    • 选择 Azure Active Directory
    • 选择快速管理模式并在此过程中创建一个新的 Azure AD 应用
    • 作为请求未通过身份验证时采取的操作"选择使用 Azure AD 登录"
    • 确认

    结果:当使用浏览器打开 Web 应用程序 URL 时,它会显示登录过程,在此过程之后一切似乎都工作正常,并且 AAD 返回到应用程序,但此时它返回 HTTP 431.

    Result: When opening the web app URL with a browser, it will show the log in process, following the process everything seems to work fine and the AAD returns to the application, however at that point it returns a HTTP 431.

    进一步测试:

    • 停用身份验证,一切正常
    • 在启用身份验证的情况下,上传简单的 .html 文件而不是 Node 应用可以正常工作
    • 通过 restify 和 http 测试

    有什么想法吗?我错过了什么吗?

    Any ideas? Am I missing something?

    推荐答案

    这是一个已知问题,因为最近版本的节点对标头使用 8KB 的硬上限存在限制.EasyAuth 在请求中添加了一些非常大的标头,这可能会导致节点容器拒绝中间件容器发出的 400 请求.在此处阅读有关它的更多信息:这可以通过将应用程序设置 WEBSITE_AUTH_DISABLE_IDENTITY_FLOW 设置为 true 来缓解.这将删除我们添加到请求中的最大标头之一.此标头通常仅由 .NET Framework 和 Azure Functions 应用使用,因此此设置应该是安全的.

    This is a known issue since there is limitation with more recent versions of node that utilize a hard cap of 8KB for headers. EasyAuth adds some very large headers to the request, which can cause the node container to reject the request made by the middleware container with a 400. Read more about it here:   This can be mitigated by setting the app setting WEBSITE_AUTH_DISABLE_IDENTITY_FLOW to true. This will remove one of the largest headers we add to the request. This header is generally only used by .NET Framework and Azure Functions apps, and so this setting should be safe.

    如果问题依旧,可以尝试使用NodeJS 12版本或者增加header size参数:node server.js --max-http-header-size 81000

    If the issue still occurs, you can try with NodeJS 12 versions or increase the header size parameter: node server.js --max-http-header-size 81000

    这篇关于Azure Web 应用程序 + Node.js + Azure AD = 错误 431的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆