|
|
@@ -15,6 +15,7 @@ import org.springframework.security.oauth2.server.authorization.token.OAuth2Toke |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@@ -39,16 +40,18 @@ public class IdTokenCustomizerConfig { |
|
|
|
} |
|
|
|
if ("access_token".equals(context.getTokenType().getValue())) { |
|
|
|
UserBaseInfoDto userBaseInfoDto = userMapper.getUserBaseInfo(context.getPrincipal().getName()); |
|
|
|
context.getClaims().claims(claims -> |
|
|
|
claims.put("scope", context.getPrincipal().getAuthorities() |
|
|
|
.stream().map(GrantedAuthority::getAuthority) |
|
|
|
.collect(Collectors.toSet()))) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("username", context.getPrincipal().getName())) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("oUserId", userBaseInfoDto.getUserId())) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("clientRoleList", JSONObject.toJSONString(userBaseInfoDto.getClientRoleDtoList()))); |
|
|
|
if(Objects.nonNull(userBaseInfoDto)){ |
|
|
|
context.getClaims().claims(claims -> |
|
|
|
claims.put("scope", context.getPrincipal().getAuthorities() |
|
|
|
.stream().map(GrantedAuthority::getAuthority) |
|
|
|
.collect(Collectors.toSet()))) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("username", context.getPrincipal().getName())) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("oUserId", userBaseInfoDto.getUserId())) |
|
|
|
.claims(claims -> |
|
|
|
claims.put("clientRoleList", JSONObject.toJSONString(userBaseInfoDto.getClientRoleDtoList()))); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |