提交 fabb0580 编写于 作者: zlt2000's avatar zlt2000

增加授权类型字段

上级 e56880bb
......@@ -29,4 +29,8 @@ public class TokenVo implements Serializable {
* 所属应用
*/
private String clientId;
/**
* 授权类型
*/
private String grantType;
}
......@@ -12,6 +12,7 @@ import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -44,17 +45,21 @@ public class RedisTokensServiceImpl implements ITokensService {
if (tokenObjs != null) {
for (Object obj : tokenObjs) {
DefaultOAuth2AccessToken accessToken = (DefaultOAuth2AccessToken)obj;
//获取用户信息
Object authObj = redisRepository.get(SecurityConstants.REDIS_TOKEN_AUTH + accessToken.getValue());
OAuth2Authentication authentication = (OAuth2Authentication)authObj;
//构造token对象
TokenVo tokenVo = new TokenVo();
tokenVo.setClientId(clientId);
tokenVo.setTokenValue(accessToken.getValue());
tokenVo.setExpiration(accessToken.getExpiration());
//获取用户信息
Object authObj = redisRepository.get(SecurityConstants.REDIS_TOKEN_AUTH + accessToken.getValue());
OAuth2Authentication authentication = (OAuth2Authentication)authObj;
if (authentication != null) {
OAuth2Request request = authentication.getOAuth2Request();
tokenVo.setUsername(authentication.getName());
tokenVo.setClientId(request.getClientId());
tokenVo.setGrantType(request.getGrantType());
}
result.add(tokenVo);
}
}
......
......@@ -46,6 +46,7 @@
}, title: '到期时间'
},
{field: 'username',width:180, sort: true, title: '用户名'},
{field: 'grantType',width:180, sort: true, title: '授权类型'},
{field: 'clientId',width:180, sort: true, title: '所属应用'},
{align: 'center',width:100, toolbar: '#tokens-table-bar', title: '操作'}
]]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册