- PasswordDecryptFilter에 /internal/** 경로 제외 처리 추가
eapim-portal CI / build (push) Has been cancelled
eapim-portal Test / test (push) Has been cancelled

- 내부 API 요청 필터 동작/암호화 정책 충돌 방지
This commit is contained in:
Rinjae-gf63
2026-09-03 09:19:46 +09:00
parent 924c00968c
commit 97489d0361
@@ -24,10 +24,19 @@ import java.io.IOException;
*
* <p>기능이 꺼져 있거나 POST 가 아니면 아무것도 하지 않는다. 래퍼는 파라미터를 조회할 때만
* 복호화하므로, 봉투가 없는 요청에는 사실상 비용이 없다.</p>
*
* <p><b>{@code /internal/**} 은 대상에서 제외한다.</b> playwright 전용 테스트 정리 API
* ({@code TestCleanupInternalController} 등)는 공유 토큰({@code X-Internal-Token}) + IP 허용목록으로
* 이미 인증되는 서버-to-서버 호출이라 브라우저 암호화 대상이 아니다({@code MenuAccessInterceptor} 가
* 같은 이유로 {@code /internal/**} 을 제외하는 것과 동일 패턴). 이 경로를 필터에 그대로 태우면, 도구가
* 보내는 평문 {@code password} 파라미터가 {@code plaintext-policy=ENFORCE} 설정에 걸려 빈 문자열로
* 치환되고 내부 API 는 "필수값 누락"으로 거부한다(예: {@code /internal/test-cleanup/password}).</p>
*/
@Component
public class PasswordDecryptFilter implements Filter {
private static final String INTERNAL_API_PREFIX = "/internal/";
private final PasswordCryptoProperties properties;
private final PasswordEnvelopeCodec codec;
private final PasswordKeyStore keyStore;
@@ -50,7 +59,7 @@ public class PasswordDecryptFilter implements Filter {
}
HttpServletRequest httpRequest = (HttpServletRequest) request;
if (!"POST".equalsIgnoreCase(httpRequest.getMethod())) {
if (!"POST".equalsIgnoreCase(httpRequest.getMethod()) || isInternalApiRequest(httpRequest)) {
chain.doFilter(request, response);
return;
}
@@ -64,4 +73,9 @@ public class PasswordDecryptFilter implements Filter {
wrapper.consumeUsedKeys();
}
}
private static boolean isInternalApiRequest(HttpServletRequest request) {
String path = request.getRequestURI().substring(request.getContextPath().length());
return path.startsWith(INTERNAL_API_PREFIX);
}
}