File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
server/src/main/java/com/incial/crm/security Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,18 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
2828
2929 @ Override
3030 protected boolean shouldNotFilter (HttpServletRequest request ) {
31- return request .getServletPath ().startsWith ("/api/v1/auth/" );
31+
32+ // Allow auth endpoints
33+ if (request .getServletPath ().startsWith ("/api/v1/auth/" )) {
34+ return true ;
35+ }
36+
37+ // Allow CORS preflight
38+ if ("OPTIONS" .equalsIgnoreCase (request .getMethod ())) {
39+ return true ;
40+ }
41+
42+ return false ;
3243 }
3344
3445 @ Override
@@ -38,12 +49,6 @@ protected void doFilterInternal(
3849 FilterChain filterChain
3950 ) throws ServletException , IOException {
4051
41- // Skip CORS preflight
42- if ("OPTIONS" .equalsIgnoreCase (request .getMethod ())) {
43- filterChain .doFilter (request , response );
44- return ;
45- }
46-
4752 String authHeader = request .getHeader ("Authorization" );
4853
4954 if (authHeader == null || !authHeader .startsWith ("Bearer " )) {
@@ -90,9 +95,8 @@ protected void doFilterInternal(
9095 );
9196
9297 SecurityContextHolder .getContext ().setAuthentication (authentication );
93-
9498 }
9599
96100 filterChain .doFilter (request , response );
97101 }
98- }
102+ }
You can’t perform that action at this time.
0 commit comments