对于订阅验证,网关调用运行在密钥管理器节点上的密钥验证服务,密钥管理器访问数据库以获取验证所需的数据。
如果数据库出现故障,则有可能在运行时请求失败。
在服务器启动和为租户加载租户时,将订阅验证所需的加载信息加载到内存中。
对于任何更新,例如应用程序创建、添加订阅,都将通过事件通知流量管理器。
Gateway 将通过主题订阅此事件。
@isharac
在服务器启动和为租户加载租户时,将订阅验证所需的加载信息加载到内存中。
在 PR wso2/carbon-apimgt#8563 中,服务目前不安全。 这些服务将如何得到保障? 基本身份验证还是 OAuth?
@isharac @chamilaadhi
此外,通过此更改,我们从 JWT 和密钥验证响应有效负载下方究竟丢失了哪些属性。JWT:
{
"aud": "http://org.wso2.apimgt/gateway",
"sub": "[email protected]",
"application": {
"owner": "admin",
"tierQuotaType": "requestCount",
"tier": "10PerMin",
"name": "New App",
"id": 2,
"uuid": null
},
"scope": "am_application_scope default",
"iss": "https://localhost:9443/oauth2/token",
"tierInfo": {
"Unlimited": {
"tierQuotaType": "requestCount",
"stopOnQuotaReach": true,
"spikeArrestLimit": 0,
"spikeArrestUnit": null
}
},
"keytype": "PRODUCTION",
"subscribedAPIs": [
{
"subscriberTenantDomain": "carbon.super",
"name": "PizzaShackAPI",
"context": "/pizzashack/1.0.0",
"publisher": "admin",
"version": "1.0.0",
"subscriptionTier": "Unlimited"
}
],
"consumerKey": "some_value",
"exp": 3738643151,
"iat": 1591159504,
"jti": "some_valu2"
}
密钥验证响应
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:validateKeyResponse xmlns:ns="http://org.apache.axis2/xsd">
<ns:return xmlns:ax2129="http://keymgt.apimgt.carbon.wso2.org/xsd"
xmlns:ax2131="http://api.apimgt.carbon.wso2.org/xsd"
xmlns:ax2133="http://dto.impl.apimgt.carbon.wso2.org/xsd"
xmlns:ax2135="http://model.api.apimgt.carbon.wso2.org/xsd"
xmlns:ax2136="http://dto.api.apimgt.carbon.wso2.org/xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax2133:APIKeyValidationInfoDTO">
<ax2133:apiName>$APINAME</ax2133:apiName>
<ax2133:apiPublisher>admin</ax2133:apiPublisher>
<ax2133:apiTier xsi:nil="true" />
<ax2133:applicationId>$APPLICATION_ID</ax2133:applicationId>
<ax2133:applicationName>$APPLICATION_NAME</ax2133:applicationName>
<ax2133:applicationTier>$APPLICATION_TIER</ax2133:applicationTier>
<ax2133:authorized>true</ax2133:authorized>
<ax2133:authorizedDomains xsi:nil="true" />
<ax2133:consumerKey>fxzmLefepgKF2Qa</ax2133:consumerKey>
<ax2133:contentAware>false</ax2133:contentAware>
<ax2133:endUserName>[email protected]</ax2133:endUserName>
<ax2133:endUserToken xsi:nil="true" />
<ax2133:issuedTime>15288163</ax2133:issuedTime>
<ax2133:scopes>default</ax2133:scopes>
<ax2133:scopes>am_application_scope</ax2133:scopes>
<ax2133:spikeArrestLimit>0</ax2133:spikeArrestLimit>
<ax2133:spikeArrestUnit xsi:nil="true" />
<ax2133:stopOnQuotaReach>true</ax2133:stopOnQuotaReach>
<ax2133:subscriber>admin</ax2133:subscriber>
<ax2133:subscriberTenantDomain>carbon.super</ax2133:subscriberTenantDomain>
<ax2133:throttlingDataList>api_level_throttling_key</ax2133:throttlingDataList>
<ax2133:tier>$TIER</ax2133:tier>
<ax2133:type>$KEY_TYPE</ax2133:type>
<ax2133:userType>APPLICATION</ax2133:userType>
<ax2133:validationStatus>0</ax2133:validationStatus>
<ax2133:validityPeriod>9223376854775807</ax2133:validityPeriod>
</ns:return>
</ns:validateKeyResponse>
</soapenv:Body>
</soapenv:Envelope>
@isharac
在服务器启动和为租户加载租户时,将订阅验证所需的加载信息加载到内存中。
在 PR wso2/carbon-apimgt#8563 中,服务目前不安全。 这些服务将如何得到保障? 基本身份验证还是 OAuth?
这是通过基本身份验证来保护的。
@praminda在此更改后,我们将只有来自 Oauth 提供程序的 JWT 中的标准 JWT 声明
行。 所以我们将失去 JWT 的以下属性,
"application": {},
"tierInfo": {},
"keytype": "",
"subscribedAPIs": [],
并且只有以下属性在密钥验证响应中可用。 我对么?
<ax2133:apiName>$APINAME</ax2133:apiName>
<ax2133:apiPublisher>admin</ax2133:apiPublisher>
<ax2133:apiTier xsi:nil="true" />
<ax2133:authorized>true</ax2133:authorized>
<ax2133:authorizedDomains xsi:nil="true" />
<ax2133:consumerKey>fxzmLefepgKF2Qa</ax2133:consumerKey>
<ax2133:contentAware>false</ax2133:contentAware>
<ax2133:endUserName>[email protected]</ax2133:endUserName>
<ax2133:endUserToken xsi:nil="true" />
<ax2133:issuedTime>15288163</ax2133:issuedTime>
<ax2133:scopes>default</ax2133:scopes>
<ax2133:scopes>am_application_scope</ax2133:scopes>
<ax2133:userType>APPLICATION</ax2133:userType>
<ax2133:validationStatus>0</ax2133:validationStatus>
<ax2133:validityPeriod>9223376854775807</ax2133:validityPeriod>
这是实施的。
是否有任何考虑允许用户配置此行为? 宁愿能够在 JWT 中获取所有信息,也不愿依赖 JMS 订阅来保持最新状态。 或者至少是一种使用数据库中的所有订阅生成 JWT 的方法? (特别是与 micro-gw 一起使用时)。
嗨@christian-morin
我们没有计划使其可配置,因为这是现在的默认行为。
并且第三方密钥管理器不知道订阅元数据(因为数据库不是共享的),从第三方 KM 生成的 JWT 不能包含订阅数据。
如果您可以分享您的具体要求,也许我们可以提出解决方案。
我们的要求是在 APIM 的同时使用 Micro-Gateway。 用户在 APIM 中生成 JWT 并使用它们来访问单个 Micro-GW:s。 以前所有订阅的 API 都存在于 JWT 元数据中,并且可以由 Micro-GW 进行“离线”验证。 这个新设置需要我们所有的 Micro-GW 实例监听 JMS 订阅以保持最新状态? (并且无法在 JWT 中验证哪些订阅可供客户端使用)
我只是在想,可能有数百个 micro-GW:s 调试为什么有人收到 401 会很麻烦……如果主题未注册,我们是否需要重新启动 Micro-GW 以使其成功下载所有订阅元数据,如果在 Micro-GW 启动时 APIM 没有响应会发生什么。将所有订阅cribedAPI:s和元数据附加在 JWT 元数据
嗨@christian-morin
为了支持您的用例,我们可以提供 2 个选项。
选项1:
使用 APIM 3.1.0 和 MG 3.2.0
选项 2:
使用 API-M 3.2.0 并按照 [1] 中的说明自定义 TokenIssuer。
在这种情况下,您需要与密钥管理器节点共享 APIM 数据库,并且能够在 JWT 中添加所需的声明。
希望这可以帮助!
[1] https://is.docs.wso2.com/en/latest/learn/extension-points-for-oauth/#oauth -token-generator
嗨@isharac
感谢您的答复。 我认为选项 1 不是一个很好的长期解决方案,因为我们永远无法升级产品? ;)
我怀疑我们必须按照您的建议编写一个定制的 TokenIssuer,但很高兴知道这应该是可能的。 谢谢你。
最有用的评论
我们的要求是在 APIM 的同时使用 Micro-Gateway。 用户在 APIM 中生成 JWT 并使用它们来访问单个 Micro-GW:s。 以前所有订阅的 API 都存在于 JWT 元数据中,并且可以由 Micro-GW 进行“离线”验证。 这个新设置需要我们所有的 Micro-GW 实例监听 JMS 订阅以保持最新状态? (并且无法在 JWT 中验证哪些订阅可供客户端使用)
我只是在想,可能有数百个 micro-GW:s 调试为什么有人收到 401 会很麻烦……如果主题未注册,我们是否需要重新启动 Micro-GW 以使其成功下载所有订阅元数据,如果在 Micro-GW 启动时 APIM 没有响应会发生什么。将所有订阅cribedAPI:s和元数据附加在 JWT 元数据