1919
2020public class JwtUserIdValidationFilter implements Filter {
2121
22+ private static final String HEALTH_ENDPOINT = "/health" ;
23+ private static final String VERSION_ENDPOINT = "/version" ;
24+
2225 private final JwtAuthenticationUtil jwtAuthenticationUtil ;
2326 private final Logger logger = LoggerFactory .getLogger (this .getClass ().getName ());
2427 private final String allowedOrigins ;
@@ -39,8 +42,8 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
3942 String contextPath = request .getContextPath ();
4043
4144 // FIRST: Check for health and version endpoints - skip ALL processing
42- if (path .equals ("/health" ) || path .equals ("/version" ) ||
43- path .equals (contextPath + "/health" ) || path .equals (contextPath + "/version" )) {
45+ if (path .equals (HEALTH_ENDPOINT ) || path .equals (VERSION_ENDPOINT ) ||
46+ path .equals (contextPath + HEALTH_ENDPOINT ) || path .equals (contextPath + VERSION_ENDPOINT )) {
4447 logger .info ("Skipping JWT validation for monitoring endpoint: {}" , path );
4548 filterChain .doFilter (servletRequest , servletResponse );
4649 return ;
@@ -86,8 +89,8 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
8689 || path .startsWith (contextPath + "/v3/api-docs" )
8790 || path .startsWith (contextPath + "/user/refreshToken" )
8891 || path .startsWith (contextPath + "/public" )
89- || path .equals (contextPath + "/health" )
90- || path .equals (contextPath + "/version" )) {
92+ || path .equals (contextPath + HEALTH_ENDPOINT )
93+ || path .equals (contextPath + VERSION_ENDPOINT )) {
9194 logger .info ("Skipping filter for path: " + path );
9295 filterChain .doFilter (servletRequest , servletResponse );
9396 return ;
0 commit comments