首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSO2 -网关令牌缓存无法工作

WSO2 -网关令牌缓存无法工作
EN

Stack Overflow用户
提问于 2017-03-20 12:14:24
回答 1查看 527关注 0票数 0

我们正在使用WSO2访问我们的一些服务。WSO2还处理身份验证。不过,我们在此身份验证方面正面临一个问题。当我们对一个令牌进行请求时,就会得到一个即将过期的活动令牌(假设还剩1秒)。电话是:

代码语言:javascript
复制
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
}

几秒钟后,我们调用API之一,该API在令牌过期时返回授权错误。然后,我们要求一个新的,工作良好。

但是,在读取网关令牌缓存时,默认情况下应该缓存令牌15分钟。我检查了配置文件,这些设置确实是正确的:

代码语言:javascript
复制
<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>

因此,我们希望在令牌到期后,调用仍能正常工作。

我们使用的是WSO2 API版本2.0.0。

我还需要检查其他配置吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-20 14:06:18

问题在于语句:"expires_in":1,因此您的令牌在1秒内过期。

因此,我们希望在令牌到期后,调用仍能正常工作。

不,一旦令牌过期,它也将从缓存中移除(或者--至少缓存不会返回它)

默认的令牌生存期可以在identity.xml配置文件中设置,请参阅文献资料

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42903336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档