打印箱唛修改 尾程垮桥事件提交
This commit is contained in:
@@ -23,20 +23,21 @@ public class JwtClaimsMapper {
|
||||
addRoles(permissions, session.roles());
|
||||
}
|
||||
|
||||
String appCode = jwt.getClaimAsString("app_code");
|
||||
String appCode = firstNonBlank(jwt.getClaimAsString("appCode"), jwt.getClaimAsString("app_code"));
|
||||
if (appCode != null && !appCode.isBlank()) {
|
||||
permissions.add("APP_" + appCode.toUpperCase(java.util.Locale.ROOT));
|
||||
}
|
||||
String username = firstNonBlank(jwt.getClaimAsString("username"),
|
||||
jwt.getClaimAsString("preferred_username"), jwt.getSubject());
|
||||
Long userId = longClaim(jwt, "user_id");
|
||||
Long userId = longClaim(jwt, "userId");
|
||||
if (userId == null) userId = longClaim(jwt, "user_id");
|
||||
AuthenticatedUser user = new AuthenticatedUser(
|
||||
userId == null ? longValue(jwt.getSubject()) : userId,
|
||||
longClaim(jwt, "tenant_id"),
|
||||
longClaimEither(jwt, "tenantId", "tenant_id"),
|
||||
longClaim(jwt, "operator_tenant_id"),
|
||||
longClaim(jwt, "membership_id"),
|
||||
username,
|
||||
jwt.getClaimAsString("app_code"),
|
||||
appCode,
|
||||
jwt.getClaimAsString("client_type"),
|
||||
permissions,
|
||||
Boolean.TRUE.equals(jwt.getClaim("impersonated")),
|
||||
@@ -76,6 +77,10 @@ public class JwtClaimsMapper {
|
||||
if (value instanceof String text) return longValue(text);
|
||||
return null;
|
||||
}
|
||||
private Long longClaimEither(Jwt jwt, String first, String second) {
|
||||
Long value = longClaim(jwt, first);
|
||||
return value == null ? longClaim(jwt, second) : value;
|
||||
}
|
||||
|
||||
private String firstNonBlank(String... values) {
|
||||
for (String value : values) if (value != null && !value.isBlank()) return value;
|
||||
|
||||
Reference in New Issue
Block a user