ip 호출 X-Forwarded-For 확인

This commit is contained in:
2026-01-22 20:18:17 +09:00
parent a46b14db7f
commit 88dbb48129
4 changed files with 32 additions and 14 deletions

View File

@@ -21,11 +21,10 @@ import org.springframework.web.context.request.ServletRequestAttributes;
@RequiredArgsConstructor
public class CustomAuthenticationProvider implements AuthenticationProvider {
private final MembersRepository membersRepository;
ServletRequestAttributes attr =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
private final MembersRepository membersRepository;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
@@ -61,7 +60,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
// front에서 전달한 사용자 ip 등록
HttpServletRequest req = (attr != null) ? attr.getRequest() : null;
String ip = (req != null) ? HeaderUtil.get(req, "kamco-userIp") : null;
String ip = (req != null) ? HeaderUtil.get(req, "kamco-user-ip") : null;
UsernamePasswordAuthenticationToken token =
new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());