Skip to content

Commit

Permalink
refactor(message): additionalMessage 변수명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed Nov 17, 2024
1 parent 060fa83 commit 0345e73
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ private AccountLockInfo createAccountLockInfo(String memberId) {

private void sendSlackBanNotification(HttpServletRequest request, String memberId) {
String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(memberId).getMemberName();
String additionalMessage = "ID: " + memberId + ", Name: " + memberName;
String memberBannedMessage = "ID: " + memberId + ", Name: " + memberName;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.MEMBER_BANNED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.MEMBER_BANNED, request, memberBannedMessage));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ private AccountLockInfo createAccountLockInfo(String memberId) {

private void sendSlackUnbanNotification(HttpServletRequest request, String memberId) {
String memberName = externalRetrieveMemberUseCase.getMemberBasicInfoById(memberId).getMemberName();
String additionalMessage = "ID: " + memberId + ", Name: " + memberName;
String memberUnbannedMessage = "ID: " + memberId + ", Name: " + memberName;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.MEMBER_UNBANNED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.MEMBER_UNBANNED, request, memberUnbannedMessage));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public String registerBlacklistIp(HttpServletRequest request, BlacklistIpRequest
BlacklistIp blacklistIp = mapper.fromDto(requestDto);
registerBlacklistIpPort.save(blacklistIp);

String additionalMessage = "Added IP: " + ipAddress;
String blacklistAddedMessage = "Added IP: " + ipAddress;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_ADDED, request,
additionalMessage));
blacklistAddedMessage));

return ipAddress;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public String removeBlacklistIp(HttpServletRequest request, String ipAddress) {
BlacklistIp blacklistIp = retrieveBlacklistIpPort.getByIpAddress(ipAddress);
removeBlacklistIpPort.delete(blacklistIp);

String additionalMessage = "Deleted IP: " + ipAddress;
String blacklistRemovedMessage = "Deleted IP: " + ipAddress;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request,
blacklistRemovedMessage));

return blacklistIp.getIpAddress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public List<String> resetBlacklistIps(HttpServletRequest request) {
.toList();
removeBlacklistIpPort.deleteAll();

String additionalMessage = "Deleted IP: ALL";
String blacklistRemovedMessage = "Deleted IP: ALL";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.BLACKLISTED_IP_REMOVED, request,
blacklistRemovedMessage));

return blacklistedIps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class AbnormalAccessIpRemoveService implements RemoveAbnormalAccessIpUseC
@Transactional
public String removeAbnormalAccessIp(HttpServletRequest request, String ipAddress) {
removeIpAccessMonitorPort.deleteById(ipAddress);
String additionalMessage = "Deleted IP: " + ipAddress;
String abnormalAccessIpDeletedMessage = "Deleted IP: " + ipAddress;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request,
abnormalAccessIpDeletedMessage));
return ipAddress;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public List<RedisIpAccessMonitor> clearAbnormalAccessIps(HttpServletRequest requ
List<RedisIpAccessMonitor> ipAccessMonitors = retrieveIpAccessMonitorPort.findAll();
clearIpAccessMonitorPort.deleteAll();

String additionalMessage = "Deleted IP: ALL";
String abnormalAccessIpClearedMessage = "Deleted IP: ALL";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_DELETED, request,
abnormalAccessIpClearedMessage));

return ipAccessMonitors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public String changeMemberRole(HttpServletRequest httpServletRequest, String mem

updateMemberPort.update(member);

String additionalMessage = String.format("[%s] %s: %s -> %s", member.getId(), member.getName(), oldRole,
String memberRoleChangedMessage = String.format("[%s] %s: %s -> %s", member.getId(), member.getName(), oldRole,
newRole);
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.MEMBER_ROLE_CHANGED, httpServletRequest,
additionalMessage));
memberRoleChangedMessage));

return memberId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ private void sendSlackLoginFailureNotification(HttpServletRequest request, Strin
String memberName = memberInfo.getMemberName();
if (memberInfo.isAdminRole()) {
request.setAttribute("member", memberId + " " + memberName);
String additionalMessage = "로그인 실패 횟수 초과로 계정이 잠겼습니다.";
String repeatedLoginFailuresMessage = "로그인 실패 횟수 초과로 계정이 잠겼습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.REPEATED_LOGIN_FAILURES, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.REPEATED_LOGIN_FAILURES, request,
repeatedLoginFailuresMessage));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class ExternalIpAccessMonitorRegisterService implements ExternalRegisterI
public void registerIpAccessMonitor(HttpServletRequest request, String ipAddress) {
RedisIpAccessMonitor redisIpAccessMonitor = getOrCreateRedisIpAccessMonitor(ipAddress);
if (redisIpAccessMonitor.isBlocked()) {
String additionalMessage = "Blocked IP: " + ipAddress;
String abnormalAccessIpBlockedMessage = "Blocked IP: " + ipAddress;
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.ABNORMAL_ACCESS_IP_BLOCKED, request,
additionalMessage));
abnormalAccessIpBlockedMessage));
}
registerIpAccessMonitorPort.save(redisIpAccessMonitor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,26 @@ private boolean verifyIpAddressAccess(HttpServletResponse response) throws IOExc
private void sendAuthenticationSuccessAlertSlackMessage(HttpServletRequest request) {
String path = request.getRequestURI();
if (WhitelistPathMatcher.isSwaggerIndexEndpoint(path)) {
String additionalMessage = "API 문서에 대한 접근이 허가되었습니다.";
String apiDocsAccessMessage = "API 문서에 대한 접근이 허가되었습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage));
} else if (WhitelistPathMatcher.isActuatorRequest(path)) {
String additionalMessage = "Actuator에 대한 접근이 허가되었습니다.";
String actuatorAccessMessage = "Actuator에 대한 접근이 허가되었습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage));
}
}

private void sendAuthenticationFailureAlertSlackMessage(HttpServletRequest request) {
String path = request.getRequestURI();
if (WhitelistPathMatcher.isSwaggerIndexEndpoint(path)) {
String additionalMessage = "API 문서에 대한 접근이 거부되었습니다.";
String apiDocsAccessMessage = "API 문서에 대한 접근이 거부되었습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.API_DOCS_ACCESS, request, apiDocsAccessMessage));
} else if (WhitelistPathMatcher.isActuatorRequest(path)) {
String additionalMessage = "Actuator에 대한 접근이 거부되었습니다.";
String actuatorAccessMessage = "Actuator에 대한 접근이 거부되었습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.ACTUATOR_ACCESS, request, actuatorAccessMessage));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ private boolean authenticateToken(HttpServletRequest request, HttpServletRespons
private void sendSecurityAlertSlackMessage(HttpServletRequest request, RedisToken redisToken) {
if (redisToken.isAdminToken()) {
request.setAttribute("member", redisToken.getId());
String additionalMessage = "토큰 발급 IP와 다른 IP에서 접속하여 토큰을 삭제하였습니다.";
String duplicateLoginMessage = "토큰 발급 IP와 다른 IP에서 접속하여 토큰을 삭제하였습니다.";
eventPublisher.publishEvent(
new NotificationEvent(this, SecurityAlertType.DUPLICATE_LOGIN, request, additionalMessage));
new NotificationEvent(this, SecurityAlertType.DUPLICATE_LOGIN, request, duplicateLoginMessage));
}
}
}

0 comments on commit 0345e73

Please sign in to comment.