From 9d2e1fd4ffcf1ac9640504009ecc9d01a7e021a9 Mon Sep 17 00:00:00 2001 From: forge-bot Date: Mon, 13 Jul 2026 10:30:35 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=EC=A6=9D/=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=97=85=EB=AC=B4=20=EA=B7=9C=EC=B9=99=EA=B3=BC=20=EC=A0=84?= =?UTF-8?q?=ED=99=98=20=EB=B6=88=EB=B3=80=EC=8B=9D=20=EC=B6=94=EC=B6=9C=20?= =?UTF-8?q?(codex-bais-final3-20260713-192718-BAIS-SPRING-ANA-AUTH-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomAuthenticationEntryPoint.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 auth-migration/src/main/java/com/example/auth/security/CustomAuthenticationEntryPoint.java diff --git a/auth-migration/src/main/java/com/example/auth/security/CustomAuthenticationEntryPoint.java b/auth-migration/src/main/java/com/example/auth/security/CustomAuthenticationEntryPoint.java new file mode 100644 index 0000000..fae7d3b --- /dev/null +++ b/auth-migration/src/main/java/com/example/auth/security/CustomAuthenticationEntryPoint.java @@ -0,0 +1,46 @@ +package com.example.auth.security; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.http.MediaType; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.time.Instant; +import java.util.Map; + +/** + * Custom Authentication Entry Point - preserves error response format. + * Maps to AUTH_001, AUTH_003, AUTH_010 error codes. + */ +@Component +public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { + + private final ObjectMapper objectMapper; + + public CustomAuthenticationEntryPoint(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void commence( + HttpServletRequest request, + HttpServletResponse response, + AuthenticationException authException) throws IOException { + + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); + + Map errorResponse = Map.of( + "code", "AUTH_001", + "message", "Authentication required", + "timestamp", Instant.now().toString(), + "path", request.getRequestURI() + ); + + objectMapper.writeValue(response.getOutputStream(), errorResponse); + } +}