cl
4 天以前 cfe1f5bce95f2a77d391417763e3e13820781e89
rsf-server/src/main/java/com/vincent/rsf/server/common/security/JwtAuthenticationFilter.java
@@ -56,9 +56,12 @@
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
        String access_token = JwtUtil.getAccessToken(request);
        // FILTER_PATH 含 /wcs/** 时会清空 token;空板出库页需带 JWT 做 @PreAuthorize,故 /wcs/empty/** 保留 token
        String servletPath = request.getServletPath();
        boolean keepWcsEmptyJwt = servletPath != null && servletPath.startsWith("/wcs/empty");
        for (String filterPath : SecurityConfig.FILTER_PATH) {
            AntPathRequestMatcher antPathMatcher = new AntPathRequestMatcher(filterPath);
            if (antPathMatcher.matches(request)) {
            if (antPathMatcher.matches(request) && !keepWcsEmptyJwt) {
                access_token = "";
            }
        }
@@ -66,10 +69,11 @@
            try {
                User user;
                if (WHITE_KEY.contains(access_token)) {
                    user = userService.getByUsername("openapi", 2L);
                    user = userService.getByUsername("root", 1L);
                    if (user == null) {
                        throw new UsernameNotFoundException("Username not found");
                    }
                    userService.setUserAuthInfo(user);
                    List<Menu> authorities = user.getAuthorities().stream()
                            .filter(m -> !Cools.isEmpty(m.getAuthority())).collect(Collectors.toList());
                    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
@@ -83,6 +87,7 @@
                    if (user == null) {
                        throw new UsernameNotFoundException("Username not found");
                    }
                    userService.setUserAuthInfo(user);
                    List<Menu> authorities = user.getAuthorities().stream()
                            .filter(m -> !Cools.isEmpty(m.getAuthority())).collect(Collectors.toList());
                    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(