RefreshTokenCreator 可以根据client信息和user的信息生成一个jwt 格式的refresh token。
refresh token之后,之前的access token、id token、refresh token等都还能使用
什么情况下会生成refresh token?
首先当前client的authorizedgranttypes字段要包含refresh_code,其次还要满足如下的条件,其中isRestrictRefreshGrant是被jwt.token.refresh.restrict_grant控制的:
/**
* 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.