从WSO2 Api Manager / Gateway中的调解员获取租户ID /域

时间:2015-09-09 16:12:46

标签: wso2 wso2carbon wso2-am

此问题基于this other

使用描述here的过程安装IS和APIM,并尝试其他问题的答案后,标题不会添加到请求中。

调试日志输出,表示属性已设置,但认证完成后(也是误导性日志消息),以及超级域。

我公开的API是一个简单的烧瓶应用程序,它打印出标题,调用都是使用API​​商店提供的标记完成的,如果我硬编码标题值的值,则正确添加。 / p>

 [2015-09-09 14:48:01,229] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:03,257] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,872] DEBUG - PrivilegedCarbonContext Resolving tenant id from tenant domain
 [2015-09-09 14:48:04,873] DEBUG - PrivilegedCarbonContext Resolving tenant id from tenant domain
 [2015-09-09 14:48:04,873] DEBUG - OAuthAuthenticator Received Token 9d2224bd96a4b6245bcb272415515a2
 [2015-09-09 14:48:04,873] DEBUG - OAuthAuthenticator Default Version API invoked
 [2015-09-09 14:48:04,873] DEBUG - OAuthAuthenticator Removing Authorization header from headers
 [2015-09-09 14:48:04,874] DEBUG - OAuthAuthenticator Full Request Path = /callback
 [2015-09-09 14:48:04,874] DEBUG - APIKeyValidator Found resource in Cache for key: /t/test.com/test/v1/v1/callback:GET
 [2015-09-09 14:48:04,874] DEBUG - OAuthAuthenticator Matching resource is: /callback
 [2015-09-09 14:48:04,874] DEBUG - OAuthAuthenticator User is authorized to access the Resource
 [2015-09-09 14:48:04,874] DEBUG - APIAuthenticationHandler Authenticated API, authentication response relieved: API call failed reason=API_authentication_failure               transactionId=urn:uuid:bbad9a1d-be19-47a7-8676-6e85f7463113 with userAgent=curl/7.43.0 with accessToken=Bearer 9d2224bd96a4b6245bcb272415515a2 for requestURI=/t/test.com/test/v1/   callback at time=Wed Sep 09 14:48:04 UTC 2015 from clientIP=192.168.99.1, elapsedTimeInMilliseconds=0
 [2015-09-09 14:48:04,874] DEBUG - APIThrottleHandler The IP Address of the caller is :192.168.99.1
 [2015-09-09 14:48:04,874]  INFO - LogMediator To: local://axis2services/test/v1/callback, MessageID: urn:uuid:bbad9a1d-be19-47a7-8676-6e85f7463113, Direction: request
 [2015-09-09 14:48:04,875] DEBUG - WSO2Registry ==> Repository fetch of resource with key : tenant
 [2015-09-09 14:48:04,875] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,877] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,878] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,880] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,881] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,883] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,886] DEBUG - WSO2Registry ==> Repository fetch of resource with key : tenant
 [2015-09-09 14:48:04,887] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,888] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,888] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,892] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,893] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,894] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56
 [2015-09-09 14:48:04,921]  INFO - CarbonTenantInfoConfigurator >>>>>>>>>>>>>Applying Tenant Info...
 [2015-09-09 14:48:04,921]  INFO - CarbonTenantInfoConfigurator       tenant domain: carbon.super
 [2015-09-09 14:48:04,922]  INFO - CarbonTenantInfoConfigurator       tenant id: -1234
 [2015-09-09 14:48:04,922]  INFO - CarbonTenantInfoConfigurator <<<<<<<<<<<<<<<
 [2015-09-09 14:48:05,283] DEBUG - RealmCache created authorization cache : org.wso2.carbon.caching.impl.CacheImpl@922bea56

检查来源似乎在调用调解器时,只执行令牌验证,因此,是否有办法从调解器中获取api 调用者的实际租户API网关?

1 个答案:

答案 0 :(得分:0)

如果您有类中介,那么所有将在处理程序之后执行的操作(身份验证,限制,使用计量通过处理程序执行)。如果在mediator中运行以下代码块,您将看到实际API用户的用户ID(从通过API调用发送的访问令牌派生的用户信息)。如果您发送的请求具有从API控制台生成的访问令牌,那么您将看到应用程序所有者名称为API用户。否则它将显示实际的最终用户。

synCtx.getProperty(APIMgtGatewayConstants.USER_ID);