|
@@ -6,6 +6,7 @@ import cn.dev33.satoken.exception.NotRoleException;
|
|
import cn.dev33.satoken.stp.StpInterface;
|
|
import cn.dev33.satoken.stp.StpInterface;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import com.xy.utils.R;
|
|
import com.xy.utils.R;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
@@ -18,9 +19,12 @@ import java.util.List;
|
|
* 权限校验
|
|
* 权限校验
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@AllArgsConstructor
|
|
@RestControllerAdvice
|
|
@RestControllerAdvice
|
|
public class SaTokenAuthorize implements StpInterface {
|
|
public class SaTokenAuthorize implements StpInterface {
|
|
|
|
|
|
|
|
+ private SaTokenAuthorizeConfig saTokenAuthorizeConfig;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 校验权限
|
|
* 校验权限
|
|
*
|
|
*
|
|
@@ -38,11 +42,16 @@ public class SaTokenAuthorize implements StpInterface {
|
|
throw new NotLoginException(null, null, null);
|
|
throw new NotLoginException(null, null, null);
|
|
}
|
|
}
|
|
//菜单权限
|
|
//菜单权限
|
|
- List<String> permissionList = StpUtil.getPermissionList(byId);
|
|
|
|
- if (!permissionList.contains(permission.substring(1).replaceAll("/", "."))) {
|
|
|
|
- throw new NotPermissionException(null);
|
|
|
|
|
|
+ if (saTokenAuthorizeConfig.getEnablePermission() != null && saTokenAuthorizeConfig.getEnablePermission()) {
|
|
|
|
+ List<String> permissionList = StpUtil.getPermissionList(byId);
|
|
|
|
+ if (!permissionList.contains(permission.substring(1).replaceAll("/", "."))) {
|
|
|
|
+ throw new NotPermissionException(null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//角色权限
|
|
//角色权限
|
|
|
|
+ if (saTokenAuthorizeConfig.getEnableRole() != null && saTokenAuthorizeConfig.getEnableRole()) {
|
|
|
|
+
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|