[英]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.