|
@@ -165,14 +165,6 @@ public class AuthorizationServerConfigure extends AuthorizationServerConfigurerA
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- // 设置 Access Token 有效期为 1 分钟
|
|
|
|
- // 默认Access Token 有效期:2分钟
|
|
|
|
- // tokenServices.setAccessTokenValiditySeconds(60);
|
|
|
|
-
|
|
|
|
- // 设置 Refresh Token 有效期为 365 天
|
|
|
|
- // 默认Refresh Token 有效期:7天
|
|
|
|
- // tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 365);
|
|
|
|
-
|
|
|
|
// 请求回来的token都会变.但是请求的refresh token不会续期(false)或者重置为初始化时间(true)
|
|
// 请求回来的token都会变.但是请求的refresh token不会续期(false)或者重置为初始化时间(true)
|
|
tokenServices.setReuseRefreshToken(true);
|
|
tokenServices.setReuseRefreshToken(true);
|
|
// 支持刷新令牌(默认false)
|
|
// 支持刷新令牌(默认false)
|
|
@@ -193,8 +185,12 @@ public class AuthorizationServerConfigure extends AuthorizationServerConfigurerA
|
|
tokenServices.setAuthenticationManager(new ProviderManager(list));
|
|
tokenServices.setAuthenticationManager(new ProviderManager(list));
|
|
}
|
|
}
|
|
|
|
|
|
- // tokenServices.setAccessTokenValiditySeconds(60);
|
|
|
|
- log.info("tokenServices: {}", tokenServices);
|
|
|
|
|
|
+ // 设置 Access Token 有效期为 365 天;默认Access Token 有效期:2分钟
|
|
|
|
+ // tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24 * 365);
|
|
|
|
+
|
|
|
|
+ // 设置 Refresh Token 有效期为 2 小时;默认Refresh Token 有效期:7天
|
|
|
|
+ // tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 2);
|
|
|
|
+
|
|
return tokenServices;
|
|
return tokenServices;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -214,8 +210,9 @@ public class AuthorizationServerConfigure extends AuthorizationServerConfigurerA
|
|
additionalInformation.put("clientId", authentication.getOAuth2Request().getClientId());
|
|
additionalInformation.put("clientId", authentication.getOAuth2Request().getClientId());
|
|
additionalInformation.put("resourceIds", authentication.getOAuth2Request().getResourceIds());
|
|
additionalInformation.put("resourceIds", authentication.getOAuth2Request().getResourceIds());
|
|
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInformation);
|
|
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInformation);
|
|
|
|
+
|
|
// 设置过期时间
|
|
// 设置过期时间
|
|
- ((DefaultOAuth2AccessToken) accessToken).setExpiration(new Date(System.currentTimeMillis() + 30 * 1000));
|
|
|
|
|
|
+ ((DefaultOAuth2AccessToken) accessToken).setExpiration(new Date(System.currentTimeMillis() + 60L * 60 * 24 * 365 * 1000));
|
|
}
|
|
}
|
|
return accessToken;
|
|
return accessToken;
|
|
}
|
|
}
|