|
@@ -40,21 +40,21 @@ public class PermissionValidateInterceptor implements Filter {
|
|
*/
|
|
*/
|
|
private boolean validate(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
private boolean validate(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
// 判断是否拥有访问权限
|
|
// 判断是否拥有访问权限
|
|
- SecurityProperties.Permission permission =
|
|
|
|
- ApplicationContextHolder.getBean(SecurityProperties.class).getPermission();
|
|
|
|
- if (!permission.isEnabled()) {
|
|
|
|
|
|
+ SecurityProperties properties = ApplicationContextHolder.getBean(SecurityProperties.class);
|
|
|
|
+ SecurityProperties.Permission config = properties.getPermission();
|
|
|
|
+ if (StringUtils.isEmpty(config.getPermit()) && StringUtils.isEmpty(config.getRequire())) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
String method = request.getMethod(), uri = HttpUtils.getRequestURI(request);
|
|
String method = request.getMethod(), uri = HttpUtils.getRequestURI(request);
|
|
- if (StringUtils.isPath(permission.getPermit(), uri) || (StringUtils.nonEmpty(permission.getRequire())
|
|
|
|
- && !StringUtils.isPath(permission.getRequire(), uri))
|
|
|
|
|
|
+ if (StringUtils.isPath(config.getPermit(), uri) || (StringUtils.nonEmpty(config.getRequire())
|
|
|
|
+ && !StringUtils.isPath(config.getRequire(), uri))
|
|
|| SecurityContextHolder.hasPermission(method, uri)) {
|
|
|| SecurityContextHolder.hasPermission(method, uri)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// 无访问权限
|
|
// 无访问权限
|
|
log.warn(HttpUtils.getExceptionMessage(request, HttpStatus.FORBIDDEN, "Permission denied"));
|
|
log.warn(HttpUtils.getExceptionMessage(request, HttpStatus.FORBIDDEN, "Permission denied"));
|
|
- if (StringUtils.isPath(permission.getIgnore(), uri)) {
|
|
|
|
|
|
+ if (StringUtils.isPath(config.getIgnore(), uri)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
response.setStatus(HttpStatus.FORBIDDEN.value());
|
|
response.setStatus(HttpStatus.FORBIDDEN.value());
|