繁体   English   中英

在WSO2 Api Manager /网关中从调解员获取租户ID /域

[英]Getting tenant id/domain from mediators in WSO2 Api Manager / Gateway

这个问题是基于另一个

使用此处描述的过程安装IS和APIM并尝试回答其他问题后,标头未添加到请求中。

调试日志输出表明设置了属性,但是身份验证完成后(也是误导性的日志消息),并且具有上级域。

我公开的API是一个简单的flask应用程序,可以打印出标头,并且所有调用均使用API​​商店提供的令牌完成。如果我对标头值的值进行硬编码,则会正确添加该值。

 [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 调用者的实际租户?

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

synCtx.getProperty(APIMgtGatewayConstants.USER_ID);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM