1. org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer
此类默认配置了创建access_token需要用到的一些组件,
比如: AuthorizationServerTokenServices(默认为DefaultTokenServices);TokenStore等
2. 如果用的默认配置,那么会调用到org.springframework.security.oauth2.provider.token.DefaultTokenServices里的
createAccessToken(OAuth2Authentication authentication)来生成token。首先会从TokenStore里检查有没有存在过,如果已经存在了,直接返回existingAccessToken. 所以同一个用户如果调了登陆接口多次,在原来token没有过期的情况下,会返回同样的token。
@Transactional
public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication) throws AuthenticationException {
OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
OAuth2RefreshToken refreshToken = null;
if (existingAccessToken != null) {
if (existingAccessToken.isExpired()) {
if (e