|
@@ -2,6 +2,7 @@ package com.chelvc.framework.oauth.context;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.time.Duration;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
@@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
|
|
import org.springframework.security.oauth2.jwt.Jwt;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* Oauth上下文工具类
|
|
@@ -176,7 +178,14 @@ public class OauthContextHolder {
|
|
|
* @return 授权信息
|
|
|
*/
|
|
|
public static String getAuthority(Jwt jwt) {
|
|
|
- return jwt == null ? null : StringUtils.ifEmpty(jwt.getClaimAsString(JWT_CLAIM_AUTHORITIES), (String) null);
|
|
|
+ if (jwt == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> authorities = jwt.getClaimAsStringList(JWT_CLAIM_AUTHORITIES);
|
|
|
+ if (CollectionUtils.isEmpty(authorities)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return StringUtils.ifEmpty(StringUtils.join(authorities, ","), (String) null);
|
|
|
}
|
|
|
|
|
|
/**
|