Skip to content

Commit e24ac4c

Browse files
authored
fix: preRegister 보안 코드 불필요한 로그 삭제 및 에러코드 문구 수정
1 parent 011e28f commit e24ac4c

9 files changed

Lines changed: 1 addition & 38 deletions

File tree

backend/src/main/java/com/back/global/error/code/SecurityErrorCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum SecurityErrorCode implements ErrorCode {
2222
IDC_IP_BLOCKED(HttpStatus.FORBIDDEN, "VPN 또는 프록시를 사용 중입니다. 해제 후 다시 시도해주세요."),
2323

2424
// Device Fingerprint
25-
SUSPICIOUS_ACTIVITY(HttpStatus.BAD_REQUEST, "비정상적인 요청이 감지되었습니다. 잠시 후 다시 시도해주세요."),
25+
SUSPICIOUS_ACTIVITY(HttpStatus.BAD_REQUEST, "비정상적인 요청이 감지되었습니다. 24시간 후 다시 시도하거나 고객센터에 문의해주세요."),
2626
FINGERPRINT_BLOCKED(HttpStatus.FORBIDDEN, "비정상적인 활동이 감지되어 차단되었습니다. 고객센터에 문의해주세요.");
2727

2828
private final HttpStatus httpStatus;

backend/src/main/java/com/back/global/recaptcha/service/ReCaptchaService.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ private ReCaptchaResponse sendVerificationRequest(String token, String remoteIp)
6767
ReCaptchaResponse.class
6868
);
6969

70-
log.debug("reCAPTCHA 검증 응답: success={}, score={}, action={}, errorCodes={}",
71-
response != null ? response.isSuccess() : null,
72-
response != null ? response.getScore() : null,
73-
response != null ? response.getAction() : null,
74-
response != null ? response.getErrorCodes() : null
75-
);
76-
7770
return response;
7871

7972
} catch (RestClientException e) {
@@ -100,7 +93,5 @@ private void validateResponse(ReCaptchaResponse response) {
10093
log.warn("reCAPTCHA 점수가 너무 낮습니다: {} (최소: {})", response.getScore(), MINIMUM_SCORE);
10194
throw new ErrorException(CommonErrorCode.RECAPTCHA_SCORE_TOO_LOW);
10295
}
103-
104-
log.info("reCAPTCHA 검증 성공: score={}, action={}", response.getScore(), response.getAction());
10596
}
10697
}

backend/src/main/java/com/back/global/security/filter/FingerprintRecordFilter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,13 @@ protected void doFilterInternal(
8585

8686
// 429 Too Many Requests는 RateLimitFilter에서 이미 기록했으므로 건너뜀 (중복 방지)
8787
if (status == 429) {
88-
log.debug("[FingerprintRecordFilter] 429 응답은 RateLimitFilter에서 이미 기록됨 - 건너뜀");
8988
return;
9089
}
9190

9291
boolean success = (status >= 200 && status < 300);
9392

9493
// Fingerprint 기록
9594
fingerprintService.recordAttempt(visitorId, success);
96-
97-
log.debug("[FingerprintRecordFilter] Fingerprint 기록 - visitorId: {}, status: {}, success: {}",
98-
visitorId, status, success);
9995
}
10096
}
10197

backend/src/main/java/com/back/global/security/filter/RateLimitFilter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ protected void doFilterInternal(
128128
String visitorId = request.getHeader(HEADER_DEVICE_ID);
129129
if (fingerprintService != null && visitorId != null) {
130130
fingerprintService.recordAttempt(visitorId, false);
131-
log.debug("[RateLimitFilter] Fingerprint 실패 기록 - visitorId: {}", visitorId);
132131
}
133132

134133
sendTooManyRequestsResponse(response, SecurityErrorCode.TOO_MANY_SMS_REQUESTS);
@@ -148,7 +147,6 @@ protected void doFilterInternal(
148147
String visitorId = request.getHeader(HEADER_DEVICE_ID);
149148
if (fingerprintService != null && visitorId != null) {
150149
fingerprintService.recordAttempt(visitorId, false);
151-
log.debug("[RateLimitFilter] Fingerprint 실패 기록 (Global) - visitorId: {}", visitorId);
152150
}
153151

154152
sendTooManyRequestsResponse(response, SecurityErrorCode.TOO_MANY_REQUESTS);
@@ -220,7 +218,6 @@ private String extractPhoneNumber(CachedBodyHttpServletRequest request) {
220218
}
221219
} catch (Exception e) {
222220
// JSON 파싱 실패 시 무시 (null 반환)
223-
log.debug("[RateLimitFilter] JSON Body 파싱 실패 - IP만으로 Rate Limit 적용: {}", e.getMessage());
224221
}
225222

226223
// 전화번호를 찾지 못한 경우 null 반환 (IP만으로 제한)

backend/src/main/java/com/back/global/security/filter/WhitelistFilter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ protected void doFilterInternal(
5858

5959
// 화이트리스트 확인
6060
if (isWhitelisted(clientIp)) {
61-
log.info("[WhitelistFilter] 화이트리스트 IP 감지 - IP: {} - 모든 보안 필터 우회", clientIp);
6261
request.setAttribute(WHITELISTED_IP_ATTRIBUTE, true);
6362
}
6463

backend/src/main/java/com/back/global/security/service/FingerprintService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public boolean validateFingerprint(String visitorId) {
6767

6868
// visitorId가 없으면 허용 (1차)
6969
if (visitorId == null || visitorId.isEmpty()) {
70-
log.debug("[FingerprintService] visitorId 없음 - 1차 허용");
7170
return true;
7271
}
7372

@@ -164,9 +163,6 @@ public void recordAttempt(String visitorId, boolean success) {
164163
// TTL 설정 (첫 시도 또는 갱신)
165164
long ttl = securityProperties.getFingerprint().getTtlSeconds();
166165
redisTemplate.expire(key, Duration.ofSeconds(ttl));
167-
168-
log.debug("[FingerprintService] 시도 기록 - visitorId: {}, 성공: {}, 총시도: {}",
169-
visitorId, success, totalAttempts);
170166
} catch (Exception e) {
171167
log.error("[FingerprintService] 시도 기록 실패 - visitorId: {}, 오류: {}", visitorId, e.getMessage());
172168
}

backend/src/main/java/com/back/global/security/service/IdcIpBlockService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ public void refreshIdcIpList() {
105105
// 설정된 URL들에서 IP 리스트 다운로드
106106
for (String ipListUrl : securityProperties.getIdcBlock().getIpListUrls()) {
107107
try {
108-
log.info("[IdcIpBlockService] IP 리스트 다운로드 시작 - URL: {}", ipListUrl);
109108
Set<String> cidrs = downloadIpList(ipListUrl);
110109
newCidrSet.addAll(cidrs);
111-
log.info("[IdcIpBlockService] IP 리스트 다운로드 완료 - URL: {}, 항목 수: {}", ipListUrl, cidrs.size());
112110
} catch (Exception e) {
113111
log.error("[IdcIpBlockService] IP 리스트 다운로드 실패 - URL: {}, 오류: {}", ipListUrl, e.getMessage());
114112
// 다운로드 실패해도 다른 소스는 계속 시도
@@ -126,7 +124,6 @@ public void refreshIdcIpList() {
126124
redisTemplate.opsForSet().add(REDIS_KEY_IDC_IP_LIST, newCidrSet.toArray(new String[0]));
127125
// TTL 설정 (1주일)
128126
redisTemplate.expire(REDIS_KEY_IDC_IP_LIST, 7, TimeUnit.DAYS);
129-
log.info("[IdcIpBlockService] Redis 저장 완료 - 총 {} 개 CIDR 대역", newCidrSet.size());
130127
} catch (Exception e) {
131128
log.error("[IdcIpBlockService] Redis 저장 실패 - 오류: {}", e.getMessage());
132129
}
@@ -224,8 +221,6 @@ private Set<String> parseAwsIpRangesJson(HttpURLConnection conn) throws Exceptio
224221
}
225222
}
226223
}
227-
228-
log.info("[IdcIpBlockService] AWS IP 범위 JSON 파싱 완료 - IPv4 개수: {}", cidrSet.size());
229224
}
230225

231226
return cidrSet;
@@ -251,7 +246,6 @@ public boolean isIdcIp(String ip) {
251246
synchronized (cidrCache) {
252247
for (String cidr : cidrCache) {
253248
if (isIpInCidr(ip, cidr)) {
254-
log.info("[IdcIpBlockService] IDC IP 감지 - IP: {}, CIDR: {}", ip, cidr);
255249
return true;
256250
}
257251
}
@@ -271,7 +265,6 @@ private void loadCacheFromRedis() {
271265
cidrCache.clear();
272266
cidrCache.addAll(cidrsFromRedis);
273267
}
274-
log.info("[IdcIpBlockService] Redis에서 캐시 로드 완료 - {} 개 대역", cidrsFromRedis.size());
275268
} else {
276269
log.warn("[IdcIpBlockService] Redis에 저장된 IDC IP 리스트가 없음 - 리스트 갱신 필요");
277270
}

backend/src/main/java/com/back/global/security/util/ClientIpResolver.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ private String getIpFromHeader(HttpServletRequest request, String headerName) {
9595
if (ip != null && !ip.isEmpty() && !UNKNOWN.equalsIgnoreCase(ip)) {
9696
// trustedProxyCount = 0이면 X-Forwarded-For를 신뢰하지 않음
9797
if (trustedProxyCount == 0) {
98-
log.debug("IP 추출: trustedProxyCount=0이므로 {} 헤더 무시", headerName);
9998
return null;
10099
}
101100

@@ -107,11 +106,6 @@ private String getIpFromHeader(HttpServletRequest request, String headerName) {
107106
// trustedProxyCount=2, ips=["fake", "real", "cf", "alb"] -> index=2 (마지막에서 2번째)
108107
int clientIpIndex = Math.max(0, ips.length - trustedProxyCount - 1);
109108
ip = ips[clientIpIndex].trim();
110-
111-
log.debug("IP 추출: {} 헤더에서 index {} IP 사용 (trustedProxyCount={}) - IP: {}",
112-
headerName, clientIpIndex, trustedProxyCount, ip);
113-
} else {
114-
log.debug("IP 추출: {} 헤더 사용 (단일 IP) - IP: {}", headerName, ip);
115109
}
116110
return ip;
117111
}

backend/src/main/java/com/back/global/services/sms/service/SmsService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public Long sendVerificationCode(String phoneNum) {
6565
try {
6666
String redisKey = REDIS_KEY_PREFIX + phoneNum;
6767
redisTemplate.opsForValue().set(redisKey, verificationCodeStr, Duration.ofSeconds(VERIFICATION_CODE_TTL));
68-
log.info("인증번호 발송 및 Redis 저장 완료 - 전화번호: {}", maskPhoneNumber(phoneNum));
6968
} catch (Exception e) {
7069
log.error("Redis 저장 실패 - 전화번호: {}, 오류: {}", maskPhoneNumber(phoneNum), e.getMessage());
7170
throw new ErrorException(SmsErrorCode.SMS_SEND_FAILED);
@@ -98,8 +97,6 @@ public boolean verifyCode(String phoneNum, String verificationCode) {
9897
// 인증 완료 플래그 저장 (사전등록 시 검증용, TTL: 10분)
9998
String verifiedKey = SMS_VERIFIED_PREFIX + phoneNum;
10099
redisTemplate.opsForValue().set(verifiedKey, "true", Duration.ofSeconds(VERIFIED_FLAG_TTL));
101-
102-
log.info("SMS 인증 성공 및 완료 플래그 저장 - 전화번호: {}", maskPhoneNumber(phoneNum));
103100
} else {
104101
log.warn("SMS 인증 실패 - 전화번호: {}, 입력값: {}", maskPhoneNumber(phoneNum), verificationCode);
105102
throw new ErrorException(SmsErrorCode.VERIFICATION_CODE_MISMATCH);

0 commit comments

Comments
 (0)