标识服务器3 - JavaScript资源所有者带有滑动标记过期的流程
问题描述:
我正在寻找使用资源所有者流实现滑动标记过期的JavaScript应用程序。标识服务器3 - JavaScript资源所有者带有滑动标记过期的流程
我们的代码与IdentityServer3.Samples.Clients解决方案中的“JavaScript资源所有者流”项目类似。
我希望能够获得令牌一次,然后继续使用该令牌,直到它到期(滑动到期)。
在须藤代码的逻辑被如下...
- 如果令牌是未定义然后调用为gettoken(),将结果保存到所述令牌可变
- 使用该令牌变量调用的API是由身份服务器保护
我的问题是,如果令牌过期设置为60秒,我每5秒调用一次api,在13次尝试令牌已过期,但我希望令牌已被刷新。
我的客户端配置的下面是一个例子...
{
"enabled": true,
"clientId": "myClient",
"clientSecrets": [
{
"description": null,
"value": "xxxxxxxxxxx",
"expiration": null,
"type": "SharedSecret"
}
],
"clientName": "myClient",
"clientUri": null,
"logoUri": null,
"requireConsent": true,
"allowRememberConsent": true,
"flow": "ResourceOwner",
"allowClientCredentialsOnly": false,
"redirectUris": [],
"postLogoutRedirectUris": [],
"logoutUri": null,
"logoutSessionRequired": true,
"requireSignOutPrompt": false,
"allowAccessToAllScopes": false,
"allowedScopes": [
"openid",
"email",
"address",
"offline_access",
"scopeA",
"scopeB"
],
"identityTokenLifetime": 300,
"accessTokenLifetime": 60, // TODO - token expiry is only 60 seconds for testing purposes
"authorizationCodeLifetime": 300,
"absoluteRefreshTokenLifetime": 86400,
"slidingRefreshTokenLifetime": 43200,
"refreshTokenUsage": "OneTimeOnly",
"updateAccessTokenClaimsOnRefresh": false,
"refreshTokenExpiration": "Sliding",
"accessTokenType": "Reference",
"enableLocalLogin": true,
"identityProviderRestrictions": [],
"includeJwtId": false,
"configClaims": [],
"alwaysSendClientClaims": true,
"prefixClientClaims": true,
"allowAccessToAllCustomGrantTypes": false,
"allowedCustomGrantTypes": [],
"allowedCorsOrigins": [
"http://localhost"
],
"allowAccessTokensViaBrowser": true
}
答
我不知道这是一个很好的模式。纯JavaScript应用程序不应该处理offlne_access或资源所有者流。另外,把客户端的秘密推送给浏览器也是一个坏主意。
这就是为js客户端应用程序设计的隐式流程的全部原因,虽然您不会使用刷新令牌,但通过授权端点更新访问令牌的最终结果是相同的。
布洛克有这个权利在这里有很大的JS LIB:https://github.com/IdentityModel/oidc-client-js
令牌到期的令牌被硬编码。所以没有滑动到期。您需要使用刷新令牌请求新的访问令牌。 – rawel