CloudFoundry User Account and Authentication (UAA) Server Refresh Token

RefreshTokenCreator 可以根據client信息和user的信息生成一個jwt 格式的refresh token。

什麼情況下會生成refresh token?
首先當前client的authorizedgranttypes字段要包含refresh_code,其次還要滿足如下的條件:

    /**
     * Check the current authorization request to indicate whether a refresh
     * token should be issued or not.
     *
     * @param grantType the current grant type
     * @param scope
     * @return boolean to indicate if refresh token is supported
     */
    protected boolean isRefreshTokenSupported(String grantType, Set<String> scope) {
        if (!isRestrictRefreshGrant) {
            return GRANT_TYPE_AUTHORIZATION_CODE.equals(grantType) ||
                GRANT_TYPE_PASSWORD.equals(grantType) ||
                GRANT_TYPE_USER_TOKEN.equals(grantType) ||
                GRANT_TYPE_REFRESH_TOKEN.equals(grantType) ||
                GRANT_TYPE_SAML2_BEARER.equals(grantType);
        } else {
            return scope.contains(UAA_REFRESH_TOKEN);
        }
    }

可以看到只有 user token 才能被 refresh 。

  1. jti:JWT ID Claim
  2. sub: Subject Claim
  3. iat: Issued At Claim,當前時間
  4. exp:TokenValidityResolver計算得出的,先從oauth_client_details表的refresh_token_validity,如果沒有設置,則嘗試獲取當前zone的配置,此配置在identity_zone表的config字段的JSON格式的字符串中,tokenPolicy#refreshTokenValidity,如果zone級別的值也沒有設置,那就是用uaa.yml文件的配置,jwt.token.policy.global.refreshTokenValiditySeconds,如果這個值也沒有被設置的話,則使用默認值259200,此值體現在oauth-endpoints.xml文件中。
  5. cid:client id
  6. iss:Issuer Claim,獲取token的接口的url地址
  7. zid:zone id
  8. aud:request scope(client scope 和 user scope 和 user request scope的交集)計算出的resourceids;
  9. granted_scopes:request scope(client scope 和 user scope 和 user request scope的交集)
  10. amr:Authentication Method ,在UAA AuthzAuthenticationManager中設置了一個pwd的字符串;貌似就這麼一個值;
  11. auth_time:對應的access token的auth time
  12. acr:Auth Context Class Ref;
  13. az_attr: additional authorization attribute
  14. grant_type:
  15. user_name,origin,use_id:如果是user token的話,會有這三個值;
  16. revocable:如果對應的AccessToken是可回收的,或者identity_zone表的config字段的json對象的TokenPolicy的refreshTokenFormat的值爲opaque的話,revocable爲true;
  17. rev_sig:Revocation Signature - token revocation hash salted with at least client ID and client secret, and optionally various user values.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章