2017-06-01 9 views
0

リソース所有者フローを使用してJavaScriptアプリケーションでスライドトークンの有効期限を実装する予定です。Identity Server 3 - JavaScriptリソース所有者のフロー(トークンの有効期限切れ)

このコードは、IdentityServer3.Samples.Clientsソリューション内の「JavaScript Resource Owner Flow」プロジェクトに似ています。

私はトークンを一度取得し、有効期限が切れるまで(スライディング有効期限内に)そのトークンを使用し続けたいと思っています。

次のようにsudoのコードではロジックがある...

  • トークンが定義されていない場合、そのAPIを呼び出すために、このトークン変数を使用して入手トークン(呼び出し)と
  • トークン変数に結果を保存します

私の問題は、トークンの有効期限を60秒に設定し、5秒ごとに1回呼び出すと、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 
 
}

+0

トークンの有効期限は、ハードトークンでコーディングされています

Brockさんは、ここでは、この権利のための偉大なJS libにあります。したがって、スライドの有効期限はありません。リフレッシュトークンを使用して新しいアクセストークンを要求する必要があります。 – rawel

答えて

0

私は、それが良好なパターンであるか分かりません。純粋なjavascriptアプリケーションは、offlne_accessまたはリソース所有者のフローを処理すべきではありません。また、クライアントのシークレットをブラウザにプッシュするのは悪い考えです。

これは、jsクライアントアプリケーション用に設計された暗黙的なフローのすべての理由です。また、リフレッシュトークンを使用していないにもかかわらず、エンドポイントを承認してアクセストークンを更新すると、結果は同じになります。 https://github.com/IdentityModel/oidc-client-js

関連する問題