Selaa lähdekoodia

fix: 暂时暂停了 Body 有关的验证,修改了部分安全配置。

ddch@smail.nju.edu.cn 5 vuotta sitten
vanhempi
commit
bf451cc5fd

+ 18 - 18
web/src/main/java/cn/seecoder/web/infrastructure/config/AuthTools.java

@@ -23,9 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.nju.edu.gitlab.SeecoderGitlabApi;
 import com.nju.edu.gitlab.SeecoderGitlabException;
 import com.nju.edu.gitlab.vo.ProjectVO;
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -155,11 +152,12 @@ public class AuthTools {
     }
 
     public boolean checkTreeNodeOwnershipBody (HttpServletRequest request) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
-        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
-        TreeNodeUpdateBasicVO treeNodeUpdateBasicVO = mapper.readValue(requestBody, TreeNodeUpdateBasicVO.class);
-        log.info("checkTreeNodeOwnershipBody verifying treeNodeId: " + treeNodeUpdateBasicVO.getId());
-        return checkTreeNodeOwnership(treeNodeUpdateBasicVO.getId());
+//        ObjectMapper mapper = new ObjectMapper();
+//        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
+//        TreeNodeUpdateBasicVO treeNodeUpdateBasicVO = mapper.readValue(requestBody, TreeNodeUpdateBasicVO.class);
+//        log.info("checkTreeNodeOwnershipBody verifying treeNodeId: " + treeNodeUpdateBasicVO.getId());
+//        return checkTreeNodeOwnership(treeNodeUpdateBasicVO.getId());
+        return true;
     }
 
     public boolean checkTreeNodeOwnershipParam (HttpServletRequest request) {
@@ -183,11 +181,12 @@ public class AuthTools {
     }
 
     public boolean checkBugOwnershipBody (HttpServletRequest request) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
-        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
-        BugListUpdateBasicVO bugListUpdateBasicVO = mapper.readValue(requestBody, BugListUpdateBasicVO.class);
-        log.info("checkBugOwnershipBody verifying bugId: " + bugListUpdateBasicVO.getId());
-        return checkBugOwnership(bugListUpdateBasicVO.getId());
+//        ObjectMapper mapper = new ObjectMapper();
+//        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
+//        BugListUpdateBasicVO bugListUpdateBasicVO = mapper.readValue(requestBody, BugListUpdateBasicVO.class);
+//        log.info("checkBugOwnershipBody verifying bugId: " + bugListUpdateBasicVO.getId());
+//        return checkBugOwnership(bugListUpdateBasicVO.getId());
+        return true;
     }
 
     public boolean checkBugOwnershipParam (HttpServletRequest request) {
@@ -211,11 +210,12 @@ public class AuthTools {
     }
 
     public boolean checkProjPipelineBody (HttpServletRequest request) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
-        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
-        PipelineUpdateConfigVO pipelineUpdateConfigVO = mapper.readValue(requestBody, PipelineUpdateConfigVO.class);
-        log.info("checkProjPipelineBody verifying projectId: " + pipelineUpdateConfigVO.getProjectId() + " pipelineId: " + pipelineUpdateConfigVO.getPipelineId());
-        return checkProjPipeline(pipelineUpdateConfigVO.getProjectId(), pipelineUpdateConfigVO.getPipelineId());
+//        ObjectMapper mapper = new ObjectMapper();
+//        String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
+//        PipelineUpdateConfigVO pipelineUpdateConfigVO = mapper.readValue(requestBody, PipelineUpdateConfigVO.class);
+//        log.info("checkProjPipelineBody verifying projectId: " + pipelineUpdateConfigVO.getProjectId() + " pipelineId: " + pipelineUpdateConfigVO.getPipelineId());
+//        return checkProjPipeline(pipelineUpdateConfigVO.getProjectId(), pipelineUpdateConfigVO.getPipelineId());
+        return true;
     }
 
     public boolean checkProjPipelineParam (HttpServletRequest request) {

+ 2 - 2
web/src/main/java/cn/seecoder/web/infrastructure/config/WebSecurityConfig.java

@@ -125,8 +125,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/**/hook").permitAll()
                 .antMatchers("/**/query/**").permitAll()
                 // 跨域的 Options 请求进行放行
-                .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
-                .antMatchers("/**").hasAnyRole(WebSecurityConstants.STUDENT_ROLE, WebSecurityConstants.ADMIN_ROLE, WebSecurityConstants.TEACHER_ROLE)
+//                .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
+//                .antMatchers("/**").hasAnyRole(WebSecurityConstants.STUDENT_ROLE, WebSecurityConstants.ADMIN_ROLE, WebSecurityConstants.TEACHER_ROLE)
                 // 拒绝其他请求
                 .anyRequest().denyAll();
     }