在 Azure APIM 处设置的响应标头,转为小写,而不是保留确切的标头名称。以下是验证 JWT 令牌的 APIM 策略。由于令牌无效或令牌过期,JWT 验证不成功时,设置 header WWW-Authenticate
。
<policies>
<inbound>
<base />
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid." require-scheme="Bearer" output-token-variable-name="jwt">
<openid-config url="https://login.microsoftonline.com/my_tenant/v2.0/.well-known/openid-configuration" />
<audiences>
<audience>my_audience_string</audience>
</audiences>
<issuers>
<issuer>https://sts.windows.net/my_tenant/</issuer>
</issuers>
<required-claims>
<claim name="roles" match="any">
<value>clients.manage</value>
<value>clients.delete</value>
<value>clients.read</value>
</claim>
</required-claims>
</validate-jwt>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<set-header name="content-type" exists-action="override">
<value>application/json</value>
</set-header>
</outbound>
<on-error>
<base />
<choose>
<when condition="@(context.Response.StatusCode == 401)">
<set-header name="WWW-Authenticate" exists-action="override">
<value>@("Bearer realm="+context.Request.OriginalUrl.Host)</value>
</set-header>
</when>
</choose>
</on-error>
</policies>
期待响应标头WWW-Authenticate
,但实际上得到www-authenticate
(全部小写)。
这是预期的吗?