简体   繁体   English

WSO2-网关令牌缓存不起作用

[英]WSO2 - Gateway Token Cache not working

We are using WSO2 to access some of our services. 我们正在使用WSO2访问我们的某些服务。 WSO2 also handles authentication. WSO2还处理身份验证。 We are facing a problem with this authentication though. 但是,我们在此身份验证方面遇到了问题。 When we do a request for a token we get an active token which is about to expire (let's say 1 second left). 当我们请求令牌时,我们会得到一个即将过期的活动令牌(假设还剩1秒)。 Call is: 致电是:

Call: https://url.com/token
Header: Authorization - Basic Wm5VR1pDTGtVbjRyZllQOHVQVDJSUVRFeGFRYTpSMDVaQWZUNThDbWJxSW96d3NBSGdadmFVSzRh
Result:
{
  "access_token": "8b8243fa-4f74-363f-ab83-8a5752ccb3d3",
  "scope": "am_application_scope default",
  "token_type": "Bearer",
  "expires_in": 1
}

A few seconds later we make a call to one of our API's which returns an authorization error as the token has expired. 几秒钟后,我们调用了我们的一个API,由于令牌已过期,该API返回了授权错误。 We then request a new one which works fine. 然后,我们要求一个工作正常的新产品。

However upon reading up on the gateway token cache the token should be cached for 15 minutes by default. 但是,在读取网关令牌缓存后,默认情况下应将令牌缓存15分钟。 I checked our config file and the settings are indeed correct: 我检查了我们的配置文件,设置确实正确:

<CacheConfigurations>
        <!-- Enable/Disable token caching at the Gateway-->
    <EnableGatewayTokenCache>true</EnableGatewayTokenCache>
        <!-- Enable/Disable API resource caching at the Gateway-->
    <EnableGatewayResourceCache>true</EnableGatewayResourceCache>
    <!-- Enable/Disable API key validation information caching at key-management server -->
    <EnableKeyManagerTokenCache>false</EnableKeyManagerTokenCache>
    <!-- This parameter specifies whether Recently Added APIs will be loaded from the cache or not.
         If there are multiple API modification during a short time period, better to disable cache. -->
    <EnableRecentlyAddedAPICache>false</EnableRecentlyAddedAPICache>
        <!-- JWT claims Cache expiry in seconds -->
    <!--JWTClaimCacheExpiry>900</JWTClaimCacheExpiry-->
    <!-- Expiry time for the apim key mgt validation info cache -->
    <!--TokenCacheExpiry>900</TokenCacheExpiry-->
    <!-- This parameter specifies the expiration time of the TagCache. TagCache will
         only be created when this element is uncommented. When the specified
         time duration gets elapsed ,tag cache will get re-generated. -->
    <!--TagCacheDuration>120000</TagCacheDuration-->
</CacheConfigurations>

So we ware expecting that the call should still be working after the expiry of the token. 因此,我们期望在令牌到期后,该调用仍将继续工作。

We are using WSO2 API version 2.0.0. 我们正在使用WSO2 API版本2.0.0。

Any other config I need to check? 我需要检查的其他配置吗?

The problem is with the statement: "expires_in": 1 So your token expires in 1 second. 问题出在以下语句上: “ expires_in”:1因此,您的令牌将在1秒后过期。

So we ware expecting that the call should still be working after the expiry of the token. 因此,我们期望在令牌到期后,该调用仍将继续工作。

Nope, once the token expires, it will be removed from the cache as well (or - at least the cache won't return it) 不会,令牌一旦过期,它也会从缓存中删除(或者-至少缓存不会返回它)

The default token lifetime can be set set in the identity.xml config file, see the documentation 可以在identity.xml配置文件中设置默认令牌生存期,请参见文档

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

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