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 。
- jti:JWT ID Claim
- sub: Subject Claim
- iat: Issued At Claim,當前時間
- 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文件中。
- cid:client id
- iss:Issuer Claim,獲取token的接口的url地址
- zid:zone id
- aud:request scope(client scope 和 user scope 和 user request scope的交集)計算出的resourceids;
- granted_scopes:request scope(client scope 和 user scope 和 user request scope的交集)
- amr:Authentication Method ,在UAA AuthzAuthenticationManager中設置了一個pwd的字符串;貌似就這麼一個值;
- auth_time:對應的access token的auth time
- acr:Auth Context Class Ref;
- az_attr: additional authorization attribute
- grant_type:
- user_name,origin,use_id:如果是user token的話,會有這三個值;
- revocable:如果對應的AccessToken是可回收的,或者identity_zone表的config字段的json對象的TokenPolicy的refreshTokenFormat的值爲opaque的話,revocable爲true;
- rev_sig:Revocation Signature - token revocation hash salted with at least client ID and client secret, and optionally various user values.