@@ -0,0 +1,84 @@
+package nextstep.security.filter;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import nextstep.security.AuthenticationException;
+import nextstep.security.config.Authentication;
+import nextstep.security.config.AuthenticationManager;
+import nextstep.security.config.BasicAuthenticationToken;
+import nextstep.security.config.SecurityContextHolder;
+
+import java.util.List;
+
+import static org.springframework.http.HttpHeaders.AUTHORIZATION;
+
+public class BasicAuthFilter implements Filter {
+
+    private static final List<String> TARGET_URL = List.of("/members");
+
+    private final AuthenticationManager authenticationManager;
+
+    public BasicAuthFilter(AuthenticationManager authenticationManager) {
+        this.authenticationManager = authenticationManager;
+    }
+
+    @Override
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException {
+        boolean isHttpServlet = servletRequest instanceof HttpServletRequest && servletResponse instanceof HttpServletResponse;
+        if (isHttpServlet) {
+            HttpServletRequest request = (HttpServletRequest) servletRequest;
+            HttpServletResponse response = (HttpServletResponse) servletResponse;
+
+            try {
+                boolean notTarget = isNotTarget(request);
+                if (notTarget) {
+                    filterChain.doFilter(request, response);
+                    return;
+                }
+                // 타겟일 경우
+                checkAuthentication(request);
+                filterChain.doFilter(request, response);
+            } catch (Exception e) {
+                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+            }
+            return;
+        }
+        throw new ServletException("BasicAuthFilter only supports HTTP requests");
+    }
+
+    private boolean isNotTarget(HttpServletRequest request) {
+        String requestURI = request.getRequestURI();
+        return TARGET_URL.stream()
+                .filter(requestURI::startsWith)
+                .findAny()
+                .isEmpty();
+    }
+
+    private void checkAuthentication(HttpServletRequest request) {
+        try {
+            String authorizationHeader = getAuthorizationHeader(request);
+            if (authorizationHeader == null) throw new AuthenticationException("Missing authorization header");
+
+            Authentication authentication = authenticationManager.authenticate(new BasicAuthenticationToken(authorizationHeader));
+            if (!authentication.isAuthenticated()) {
+                throw new AuthenticationException();
+            }
+            SecurityContextHolder.getContext().setAuthentication(authentication);
+        } catch (AuthenticationException e) {
+            SecurityContextHolder.clearContext();
+            throw e;
+        }
+
+    }
+
+    private static String getAuthorizationHeader(HttpServletRequest request) {
+        return request.getHeader(AUTHORIZATION);
+    }
+
+
+}

리뷰: 피드백 반영하겠습니다! 감사합니다 :)
이번 미션에서는 기본적으로 security의 동작 원리 중심으로 보고있어 신경을 쓰지 못했지만 가독성도 고려해서 작성해보겠습니다! 👍