1. 更新语法检查
This commit is contained in:
parent
9f1d990647
commit
a9ce4ede8f
|
@ -13,9 +13,9 @@ import org.springframework.security.core.AuthenticationException;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class CommonAuthException extends AuthenticationException {
|
public class CommonAuthException extends AuthenticationException {
|
||||||
private ErrorCode err;
|
private final ErrorCode err;
|
||||||
|
|
||||||
private String[] description;
|
private final String[] description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Common auth exception.
|
* Instantiates a new Common auth exception.
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class RequestBodyFilter implements Filter {
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException,
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException,
|
||||||
ServletException {
|
ServletException {
|
||||||
ServletRequest requestWrapper = null;
|
ServletRequest requestWrapper = null;
|
||||||
if (servletRequest instanceof HttpServletRequest) {
|
if (servletRequest instanceof HttpServletRequest httpServletRequest) {
|
||||||
requestWrapper = new RequestBodyCacheWrapper((HttpServletRequest) servletRequest);
|
requestWrapper = new RequestBodyCacheWrapper(httpServletRequest);
|
||||||
}
|
}
|
||||||
//获取请求中的流如何,将取出来的字符串,再次转换成流,然后把它放入到新request对象中
|
//获取请求中的流如何,将取出来的字符串,再次转换成流,然后把它放入到新request对象中
|
||||||
// 在chain.doFiler方法中传递新的request对象
|
// 在chain.doFiler方法中传递新的request对象
|
||||||
|
|
|
@ -58,9 +58,9 @@ public class CasbinAuthorizeUtils {
|
||||||
// 添加角色资源权限
|
// 添加角色资源权限
|
||||||
roleResourceService.getRoleResourceByRoleId(role.getId()).forEach(k -> {
|
roleResourceService.getRoleResourceByRoleId(role.getId()).forEach(k -> {
|
||||||
e.addPermissionForUser(role.getName(), k.getResources().getPath(), k.getResources().getHttpMethod(),
|
e.addPermissionForUser(role.getName(), k.getResources().getPath(), k.getResources().getHttpMethod(),
|
||||||
k.getAuthorize() ? "allow" : "deny");
|
Boolean.TRUE.equals(k.getAuthorize()) ? "allow" : "deny");
|
||||||
log.trace("++++++[{}, {}, {}: {}]", role.getName(), k.getResources().getPath(),
|
log.trace("++++++[{}, {}, {}: {}]", role.getName(), k.getResources().getPath(),
|
||||||
k.getResources().getHttpMethod(), k.getAuthorize() ? "allow" : "deny");
|
k.getResources().getHttpMethod(), Boolean.TRUE.equals(k.getAuthorize()) ? "allow" : "deny");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 缓存当前权限验证器
|
// 缓存当前权限验证器
|
||||||
|
@ -85,7 +85,7 @@ public class CasbinAuthorizeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色被禁用
|
// 角色被禁用
|
||||||
if (!user.getRole().getAvailable()) {
|
if (Boolean.FALSE.equals(user.getRole().getAvailable())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,13 +96,11 @@ public class CasbinAuthorizeUtils {
|
||||||
for (String s : e.getImplicitRolesForUser(user.getRole().getName())) {
|
for (String s : e.getImplicitRolesForUser(user.getRole().getName())) {
|
||||||
Enforcer se = CasbinAuthorizeUtils.ENFORCER_POOL.get(s);
|
Enforcer se = CasbinAuthorizeUtils.ENFORCER_POOL.get(s);
|
||||||
|
|
||||||
if (s != null) {
|
if (s != null && (se.enforce(s, url, httpMethod))) {
|
||||||
if (se.enforce(s, url, httpMethod)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限(Role)表实体类
|
* 权限(Role)表实体类
|
||||||
*
|
*
|
||||||
|
@ -20,7 +23,9 @@ import lombok.NoArgsConstructor;
|
||||||
@Table("rbac_role")
|
@Table("rbac_role")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class Role {
|
public class Role implements Serializable {
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -132325343L;
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,9 +38,8 @@ public class CommonFrameworkApi {
|
||||||
@EncryptionProtocol
|
@EncryptionProtocol
|
||||||
@DecryptionProtocol
|
@DecryptionProtocol
|
||||||
@PostMapping("/version")
|
@PostMapping("/version")
|
||||||
@ResponseBody
|
|
||||||
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
|
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
|
||||||
public ProtocolResp<? extends BaseRespStatus> getVersion() {
|
public ProtocolResp<VersionResp> getVersion() {
|
||||||
return ProtocolResp.result(VersionResp.builder()
|
return ProtocolResp.result(VersionResp.builder()
|
||||||
.version(VersionInfo.builder()
|
.version(VersionInfo.builder()
|
||||||
.commitId(prgVer.getCommitId())
|
.commitId(prgVer.getCommitId())
|
||||||
|
@ -59,10 +58,9 @@ public class CommonFrameworkApi {
|
||||||
* @return the version v 2
|
* @return the version v 2
|
||||||
*/
|
*/
|
||||||
@GetMapping("/version")
|
@GetMapping("/version")
|
||||||
@ResponseBody
|
|
||||||
@EncryptionProtocol
|
@EncryptionProtocol
|
||||||
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
|
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
|
||||||
public ProtocolResp<? extends BaseRespStatus> getVersionV2() {
|
public ProtocolResp<VersionResp> getVersionV2() {
|
||||||
return ProtocolResp.result(VersionResp.builder()
|
return ProtocolResp.result(VersionResp.builder()
|
||||||
.version(VersionInfo.builder()
|
.version(VersionInfo.builder()
|
||||||
.commitId(prgVer.getCommitId())
|
.commitId(prgVer.getCommitId())
|
||||||
|
|
Loading…
Reference in New Issue