fix: 모니터링을 위해 추가 엔드포인트 인증 예외처리#77
Conversation
Summary of ChangesHello @swthewhite, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 풀 리퀘스트는 시스템 모니터링을 원활하게 하기 위해 특정 액츄에이터 엔드포인트에 대한 인증 예외 처리를 구현합니다. 이를 통해 외부 모니터링 시스템이 Prometheus, Metrics, Info 엔드포인트에 접근하여 필요한 데이터를 수집할 수 있도록 하여, 시스템의 가시성과 운영 효율성을 향상시키는 것을 목표로 합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
안녕하세요. 모니터링을 위한 엔드포인트 인증 예외 처리 변경사항을 검토했습니다. 액추에이터 엔드포인트를 WebSecurityUrl에 상수로 정의하고 SecurityConfig에 적용한 점은 좋습니다.
다만, 두 가지 중요한 점을 발견했습니다:
- 기능 미작동:
SecurityConfig에permitAll()을 추가하는 것만으로는 부족합니다.JwtAuthenticationFilter가 여전히 이 엔드포인트에 대해 JWT 토큰을 검사하여, 토큰이 없는 요청은 실패하게 됩니다. 이 필터에서도 해당 엔드포인트를 예외 처리하도록 수정해야 합니다. - 보안 위험: 일부 액추에이터 엔드포인트(
metrics,info)를 인증 없이 외부에 공개하면 민감한 정보가 노출될 수 있습니다. 이에 대한 보안 강화 방안을 고려해 보시는 것이 좋겠습니다.
자세한 내용은 각 파일의 코드 리뷰 댓글을 참고해 주세요.
| .requestMatchers("/slack/**").permitAll() | ||
| .requestMatchers(HttpMethod.GET, getReadOnlyPublicEndpoints()).permitAll() | ||
| .requestMatchers(getHealthCheckEndpoints()).permitAll() | ||
| .requestMatchers(getActuatorEndpoints()).permitAll() |
There was a problem hiding this comment.
이 설정만으로는 액추에이터 엔드포인트에 대한 인증 예외 처리가 완전하지 않을 수 있습니다. JwtAuthenticationFilter가 shouldNotFilter 로직에 따라 이 엔드포인트들을 건너뛰지 않으면, JWT 토큰이 없다는 이유로 요청이 거부될 것입니다. 이 변경 사항이 의도대로 작동하려면 JwtAuthenticationFilter.java 파일도 수정해야 합니다.
JwtAuthenticationFilter.java의 PUBLIC_ENDPOINTS 배열에 getActuatorEndpoints()를 추가하여 JWT 필터가 해당 경로를 건너뛰도록 해야 합니다.
// in src/main/java/com/project/common/security/filter/JwtAuthenticationFilter.java
import static com.project.common.util.WebSecurityUrl.getActuatorEndpoints; // import 추가
// ...
protected static final String[] PUBLIC_ENDPOINTS = Stream.of(
getHealthCheckEndpoints(),
getReadOnlyPublicEndpoints(),
getActuatorEndpoints() // 이 부분을 추가해야 합니다.
).flatMap(Arrays::stream).toArray(String[]::new);이 수정이 없으면 액추에이터 엔드포인트 호출 시 인증 오류가 발생하여 PR의 목적을 달성할 수 없습니다.
| .requestMatchers("/slack/**").permitAll() | ||
| .requestMatchers(HttpMethod.GET, getReadOnlyPublicEndpoints()).permitAll() | ||
| .requestMatchers(getHealthCheckEndpoints()).permitAll() | ||
| .requestMatchers(getActuatorEndpoints()).permitAll() |
There was a problem hiding this comment.
모니터링을 위해 액추에이터 엔드포인트를 인증 없이 외부에 공개하면 보안상 위험할 수 있습니다. 특히 /actuator/metrics와 /actuator/info 엔드포인트는 애플리케이션의 내부 동작, 사용 중인 의존성, 환경 변수 등 민감한 정보를 노출할 수 있습니다. 이는 공격자에게 시스템에 대한 중요한 정보를 제공하는 통로가 될 수 있습니다.
이러한 엔드포인트에 대한 접근을 보호하기 위해 다음 방법들을 고려해 보시는 것을 권장합니다:
- 특정 IP만 허용: 방화벽이나 Spring Security 설정을 통해 모니터링 시스템의 IP 주소만 접근을 허용합니다.
- 별도의 관리 포트 사용: 액추에이터 엔드포인트를 위한 별도의 관리 포트(
management.server.port)를 설정하고, 이 포트는 내부 네트워크에서만 접근 가능하도록 네트워크 정책을 적용합니다. - 인증 추가: 액추에이터 엔드포인트에 대해 기본 인증(Basic Auth)이나 API 키 기반의 간단한 인증을 적용합니다.
만약 애플리케이션이 외부 인터넷에 노출되지 않고 완전히 격리된 내부망에서만 운영된다면 이 위험은 낮을 수 있습니다. 하지만 그렇지 않다면 보안 강화를 심각하게 고려해야 합니다.
🍀 이슈 번호
✅ 작업 사항
⌨ 기타