未经身份验证的API

时间:2016-03-01 15:16:07

标签: wso2 wso2-am

我正在使用1.10.0新的Rest API创建API。以下是我发送的一些参数:

    body.setTransport(createList("http", "https"));
    body.setApiDefinition("{\"paths\":{\"/*\":{\"post\":{\"x-auth-type\":\"None\",\"responses\":{\"201\":{\"description\":\"Created\"}},\"x-throttling-tier\":\"Unlimited\"},\"get\":{\"x-auth-type\":\"None\",\"responses\":{\"200\":{\"description\":\"OK\"}},\"x-throttling-tier\":\"Unlimited\"},\"delete\":{\"x-auth-type\":\"None\",\"responses\":{\"200\":{\"description\":\"OK\"}},\"x-throttling-tier\":\"Unlimited\"},\"put\":{\"x-auth-type\":\"None\",\"responses\":{\"200\":{\"description\":\"OK\"}},\"x-throttling-tier\":\"Unlimited\"}}},\"swagger\":\"2.0\",\"info\":{\"title\":\"" + providerApi.getName() + "\",\"version\":\"1.0.0\"}}");
    body.setTiers(createList("Unlimited"));
    body.setVisibility(VisibilityEnum.PUBLIC);
    body.setVisibleRoles(createList());

因此API创建为Unlimited / PUBLIC。

我更改了所有三个默认层配置文件:

./opt/wso2am-1.10.0/repository/resources/default-tiers/default-res-tiers.xml
./opt/wso2am-1.10.0/repository/resources/default-tiers/default-app-tiers.xml
./opt/wso2am-1.10.0/repository/resources/default-tiers/default-tiers.xml

对于未经身份验证的角色,每分钟允许10000个请求。

        <throttle:ID throttle:type="ROLE">Unauthenticated</throttle:ID>
        <wsp:Policy>
            <throttle:Control>
                <wsp:Policy>
                    <throttle:MaximumCount>10000</throttle:MaximumCount>
                    <throttle:UnitTime>60000</throttle:UnitTime>
                </wsp:Policy>
            </throttle:Control>
        </wsp:Policy>
    </wsp:Policy>

然而,在每分钟发送60个请求之后 - API以状态代码429响应,错误日志表明超出配额...

每次更改后,我重新启动了APIM网关并重新创建了API,以防万一。

任何想法为什么网关不尊重10000限制?

1 个答案:

答案 0 :(得分:0)

API Manager将首先在服务器上读取这些文件并将内容复制到注册表中,之后,API Manager无法检查这些文件是否有任何更新。

您必须在注册表中更新您的政策。

通过管理控制台使用注册表浏览器并导航到以下位置/_system/governance/apimgt/applicationdata。您可以看到层xml文件。

  1. 登录APIM管理控制台(https://:9443 / carbon)并选择资源下的浏览

    enter image description here

  2. Nagigate to / _system / governance / apimgt / applicationdata
  3. 您将看到app-tiers.xml,res-tiers.xml,tiers.xml。
相关问题