feat: 用户所属平台标识,限制用户平台只能访问指定前缀的模块地址
This commit is contained in:
1 parent
724e9e4775
commit
dd62a85f51
7 files changed
+54
-2
No files matched your search
+5
@@ -17,6 +17,11 @@ public class SecurityConstants
|
||||
*/
|
||||
public static final String DETAILS_USERNAME = "username";
|
||||
|
||||
/**
|
||||
* 平台字段
|
||||
*/
|
||||
public static final String DETAILS_PLATFORM = "platform";
|
||||
|
||||
/**
|
||||
* 授权信息字段
|
||||
*/
|
||||
|
||||
+10
@@ -81,6 +81,16 @@ public class SecurityContextHolder
|
||||
set(SecurityConstants.USER_KEY, userKey);
|
||||
}
|
||||
|
||||
public static String getPlatform()
|
||||
{
|
||||
return get(SecurityConstants.DETAILS_PLATFORM);
|
||||
}
|
||||
|
||||
public static void setPlatform(String platform)
|
||||
{
|
||||
set(SecurityConstants.DETAILS_PLATFORM, platform);
|
||||
}
|
||||
|
||||
public static String getPermission()
|
||||
{
|
||||
return get(SecurityConstants.ROLE_PERMISSION);
|
||||
|
||||
@@ -109,6 +109,29 @@ public class JwtUtils
|
||||
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据令牌获取用户所属平台
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 所属平台
|
||||
*/
|
||||
public static String getUserPlatform(String token)
|
||||
{
|
||||
Claims claims = parseToken(token);
|
||||
return getValue(claims, SecurityConstants.DETAILS_PLATFORM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份信息获取用户所属平台
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return 所属平台
|
||||
*/
|
||||
public static String getUserPlatform(Claims claims)
|
||||
{
|
||||
return getValue(claims, SecurityConstants.DETAILS_PLATFORM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份信息获取键值
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user