简体   繁体   English

使用 WSO2 身份服务器 15 分钟后令牌到期

[英]Token Expiry after 15 minutes using WSO2 Identity Server

I have created a token by using the following API Call我使用以下 API 调用创建了一个令牌

https://wso2identityseverip:port/oauth2/token https://wso2identityseverip:port/oauth2/token

I used generated token in my API by postman which is giving an accurate response.我在我的 API 中使用了由 postman 生成的令牌,它给出了准确的响应。 But after 15 min of idle state when I use the same token in the API it is giving me an error.但是在空闲 state 15 分钟后,当我在 API 中使用相同的令牌时,它给了我一个错误。

{
"code": "900901",
"message": "Invalid Credentials",
"description": "Access failure for API: /url/1.0.0, version: 1.0.0 status: (900901) - Invalid Credentials. Make sure you have provided the correct security credentials"}

Requirement:要求:

Token should expire after an hour.令牌应在一小时后过期。 For this I have also added following configurations in my deployment.toml.为此,我还在 deployment.toml 中添加了以下配置。

[session.timeout]  idle_session_timeout= "60m" remember_me_session_timeout= "14d" extend_remember_me_session_timeout_on_auth=false

But still token is expiring in 15 min.但是令牌仍然在 15 分钟内到期。

The token expiry time is an application-wise config, and the default oauth token timeout is set to 3600 s(1h).令牌到期时间是应用程序配置,默认 oauth 令牌超时设置为 3600 秒(1 小时)。 If you haven't changed this to 15m, see the following.如果您尚未将其更改为 15m,请参见以下内容。

If you are experiencing an issue of the invalid token after session time out, it would happen if your application has enabled SSO Session Based access token binding.如果您在 session 超时后遇到令牌无效问题,如果您的应用程序启用SSO Session Based访问令牌绑定,就会发生这种情况。 Also, you have configured to revoke access token at session expiry (this is by default enabled in WSO2IS-5.11.0 onwards https://is.docs.wso2.com/en/5.11.0/setup/migrating-what-has-changed/#revoke-access-tokens-on-logoutsession-expiry ). Also, you have configured to revoke access token at session expiry (this is by default enabled in WSO2IS-5.11.0 onwards https://is.docs.wso2.com/en/5.11.0/setup/migrating-what-has -changed/#revoke-access-tokens-on-logoutsession-expiry )。

Regarding session time-out configs:关于 session 超时配置:

The idle session time-out configs that you added as follows,您添加的空闲 session 超时配置如下,

[session.timeout]  
idle_session_timeout= "60m"
remember_me_session_timeout= "14d"

are only affected to each tenant that is created after adding the configuration .仅影响添加配置后创建的每个租户 (Note the note in the green color box https://is.docs.wso2.com/en/5.11.0/learn/configuring-session-timeout/?query=idle_session_timeout#configuration ) (注意绿色框中的注释 https://is.docs.wso2.com/en/5.11.0/learn/configuring-session-timeout/?query=idle_session_timeout#configuration

In order to change the configs of the already created tenant or carbon.super tenant, you have to log into tenant via the management console, navigate to main tab -> Identity Providers -> Resident, and change the configs there.为了更改已经创建的租户或 carbon.super 租户的配置,您必须通过管理控制台登录到租户,导航到主选项卡 -> 身份提供者 -> 居民,然后在那里更改配置。

Since the error code (code: 900901) is coming from the APIM side, these answers would also help you to troubleshoot Refer:由于错误代码(代码:900901)来自 APIM 端,这些答案也将帮助您排除故障,请参阅:

I have tried this with latest IS 6.0.0.我已经用最新的 IS 6.0.0 试过了。

You can change the following.您可以更改以下内容。

  1. Default validity period for application access tokens应用程序访问令牌的默认有效期
  2. Default validity period for user access tokens用户访问令牌的默认有效期

To do you can add the following to the deployment toml (change the values as per your wish).为此,您可以将以下内容添加到部署 toml(根据您的意愿更改值)。

[oauth.token_validation]
app_access_token_validity=1800
user_access_token_validity=1800

In the latest IS, the default expiry is 3600 seconds (1hr).在最新的 IS 中,默认到期时间为 3600 秒(1 小时)。 But in your case it seems it isn't the case.但在你的情况下,情况似乎并非如此。 Adding the above config will update the config files but it will not update your already created SP configs.添加上述配置将更新配置文件,但不会更新您已经创建的 SP 配置。 The config change will take an effect from the next SP creation onwards.配置更改将从下一次创建 SP 开始生效。 To update already created SPs, you have to do it from the carbon console Service Provider settings.要更新已创建的 SP,您必须从 carbon 控制台服务提供商设置中进行。

在此处输入图像描述

When you do this, make sure to change the refresh token validity period as well.执行此操作时,请确保同时更改刷新令牌有效期。

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

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