使用Azure API管理更改为其他受众群体后,JWT验证策略突然无效

时间:2019-07-24 23:10:08

标签: azure azure-api-management

在APIM中更改JWT验证下面的Audience元素的值时,我遇到一个奇怪的问题,请参见下面的参考链接

https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#ValidateJWT

1个新链接:  https://new.onelogin.com/oidc/token

我仅从2中的旧版本更改了Audience元素的值。但是,当我尝试保存该策略时,我从APIM门户收到以下验证错误:

The element 'validate-jwt' has invalid child element 'openid-config'. List of possible elements expected: 'required-claims'.

请注意,2中的旧版本不需要'required-claims'元素。

client_id =新的XXX

    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Error: expired token or invalid token" require-expiration-time="true" require-scheme="Bearer" require-signed-tokens="true">
        <audiences>
            <audience>new xxx</audience>
        </audiences>
        <issuers>
            <issuer>https://openid-connect-eu.onelogin.com/oidc</issuer>
        </issuers>
       <openid-config url="https://openid-connect-eu.onelogin.com/oidc/.well-known/openid-configuration" />
    </validate-jwt>

2旧的url和jwt验证,并且有效。

https://old.onelogin.com/oidc/token

     client_id=old xxx

    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Error: expired token or invalid token" require-expiration-time="true" require-scheme="Bearer" require-signed-tokens="true">
        <audiences>
            <audience>old xxx</audience>
        </audiences>
        <issuers>
            <issuer>https://openid-connect-eu.onelogin.com/oidc</issuer>
        </issuers>
       <openid-config url="https://openid-connect-eu.onelogin.com/oidc/.well-known/openid-configuration" />
    </validate-jwt>

有什么主意吗?

更新

现在,即使原来有效的政策也存在问题,甚至什么都没有改变:

The element 'validate-jwt' has invalid child element 'openid-config'. List of possible elements expected: 'required-claims'.

1 个答案:

答案 0 :(得分:1)

您需要将xml中的openid-config向上移动,并将其保持在validate-jwt开头标记下。请看下面:

<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized" require-expiration-time="true" require-scheme="Bearer" require-signed-tokens="true">
    <openid-config url="" />
    <issuer-signing-keys>
        <key>Base64 Encoded Key</key>
    </issuer-signing-keys>
    <audiences>
        <audience></audience>       
    </audiences>
    <issuers>
        <issuer></issuer>
    </issuers>  
</validate-jwt>