Commit 829c55599ed7cf6c1e443db23707cf1be56b179a
1 parent
70df6393
feat: security增加了platformUserName【yunteng需要】
Showing
2 changed files
with
5 additions
and
0 deletions
... | ... | @@ -44,6 +44,7 @@ public class SecurityUser extends User { |
44 | 44 | @Getter @Setter private boolean ptTenantAdmin = false; |
45 | 45 | @Getter @Setter private boolean ptmAdmin = false; |
46 | 46 | @Getter @Setter private Set<String> roles; |
47 | + @Getter @Setter private String platformUserName; | |
47 | 48 | |
48 | 49 | public SecurityUser() { |
49 | 50 | super(); |
... | ... | @@ -60,6 +61,7 @@ public class SecurityUser extends User { |
60 | 61 | this.currentTenantId = user.getTenantId().getId().toString(); |
61 | 62 | if (user.getUserDetailsDTO() != null) { |
62 | 63 | this.currentUserId = user.getUserDetailsDTO().getId(); |
64 | + this.platformUserName = user.getUserDetailsDTO().getUsername(); | |
63 | 65 | Optional.ofNullable(user.getUserDetailsDTO().getRoles()) |
64 | 66 | .map( |
65 | 67 | roleDTOS -> { | ... | ... |
... | ... | @@ -59,6 +59,7 @@ public class JwtTokenFactory { |
59 | 59 | private static final String ROLE = "role"; |
60 | 60 | private static final String CURRENT_USER_ID = "currentUserId"; |
61 | 61 | private static final String CURRENT_TENANT_ID = "currentTenantId"; |
62 | + private static final String PLATFORM_USER_NAME = "platformUserName"; | |
62 | 63 | |
63 | 64 | private final JwtSettings settings; |
64 | 65 | |
... | ... | @@ -86,6 +87,7 @@ public class JwtTokenFactory { |
86 | 87 | claims.put(LAST_NAME, securityUser.getLastName()); |
87 | 88 | claims.put(ENABLED, securityUser.isEnabled()); |
88 | 89 | claims.put(CURRENT_USER_ID,securityUser.getCurrentUserId()); |
90 | + claims.put(PLATFORM_USER_NAME,securityUser.getPlatformUserName()); | |
89 | 91 | claims.put(ROLE,securityUser.getRoles()); |
90 | 92 | claims.put(IS_PUBLIC, principal.getType() == UserPrincipal.Type.PUBLIC_ID); |
91 | 93 | if (securityUser.getTenantId() != null) { |
... | ... | @@ -137,6 +139,7 @@ public class JwtTokenFactory { |
137 | 139 | securityUser.setPtmAdmin(securityUser.getRoles().stream().anyMatch(role -> role.equals(RoleEnum.ROLE_PLATFORM_ADMIN.name()))); |
138 | 140 | } |
139 | 141 | securityUser.setCurrentUserId(claims.get(CURRENT_USER_ID, String.class)); |
142 | + securityUser.setPlatformUserName(claims.get(PLATFORM_USER_NAME,String.class)); | |
140 | 143 | String tenantId = claims.get(TENANT_ID, String.class); |
141 | 144 | if (tenantId != null) { |
142 | 145 | securityUser.setTenantId(new TenantId(UUID.fromString(tenantId))); | ... | ... |