Forráskód Böngészése

IP주소 체크 로직 추가

gagamel 5 éve
szülő
commit
5cdf3fd143

+ 2 - 2
pom.xml

@@ -76,9 +76,9 @@
 		<dependency>
 			<groupId>com.gagaframework</groupId>
 			<artifactId>gagaframework-web-security</artifactId>
-			<version>1.7.1-RELEASE</version>
+			<version>1.7.2-RELEASE</version>
 			<scope>system</scope>
-			<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/gagaframework-web-security-1.7.1-RELEASE.jar</systemPath>
+			<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/gagaframework-web-security-1.7.2-RELEASE.jar</systemPath>
 		</dependency>
 		<dependency>
 			<groupId>com.gagaframework</groupId>

+ 33 - 2
src/main/java/com/style24/admin/support/security/TsaAuthenticationProvider.java

@@ -3,6 +3,7 @@ package com.style24.admin.support.security;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.AuthenticationProvider;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -13,13 +14,13 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.stereotype.Component;
 
 import com.style24.admin.biz.service.TsaLoginService;
+import com.style24.admin.support.security.session.TsaSession;
 import com.style24.core.support.message.TscMessageByLocale;
 import com.style24.persistence.domain.User;
 
 import lombok.extern.slf4j.Slf4j;
 
 import com.gagaframework.web.security.GagaPasswordEncoder;
-import com.gagaframework.web.util.GagaCryptoUtil;
 
 /**
  * 로그인 인증 처리
@@ -60,7 +61,6 @@ public class TsaAuthenticationProvider implements AuthenticationProvider {
 			throw new BadCredentialsException(message.getMessage("LOGN_0005"));
 		}
 
-		log.info("encoded password: {}", GagaCryptoUtil.encryptSha512(passwd));
 		boolean isMatch = passwordEncoder.matches(passwd, loginInfo.getPasswd());
 		log.info("isMatch: {}", isMatch);
 
@@ -70,6 +70,11 @@ public class TsaAuthenticationProvider implements AuthenticationProvider {
 			throw new BadCredentialsException(message.getMessage("LOGN_0002"));
 		}
 
+		// IP주소 체크
+		if (!matchIpAddress(loginInfo.getIpChkYn(), loginInfo.getIpAddr())) {
+			throw new BadCredentialsException(message.getMessage("LOGN_0005"));
+		}
+
 		// 권한 설정
 		List<SimpleGrantedAuthority> authorities = new ArrayList<>();
 		authorities.add(new SimpleGrantedAuthority(loginInfo.getRoleCd()));
@@ -87,4 +92,30 @@ public class TsaAuthenticationProvider implements AuthenticationProvider {
 		return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
 	}
 
+	/**
+	 * IP주소 체크
+	 * @param ipChkYn - IP주소체크여부
+	 * @param loginIpAddr - 로그인IP주소
+	 * @return
+	 */
+	private boolean matchIpAddress(String ipChkYn, String loginIpAddr) {
+		String requestIpAddr = TsaSession.getIpAddress();
+
+		log.info("ipChkYn: {}, request ip address: {} vs user's ip address: {}", ipChkYn, requestIpAddr, loginIpAddr);
+
+		if (ipChkYn.equals("N")) {
+			return true;
+		}
+
+		if (!StringUtils.isNotBlank(loginIpAddr)) {
+			return true;
+		}
+
+		if (!loginIpAddr.equals(requestIpAddr)) {
+			return false;
+		}
+
+		return true;
+	}
+
 }

+ 1 - 0
src/main/resources/i18n/messages/message_ko_KR.properties

@@ -30,6 +30,7 @@ LOGN_0001=\uc785\ub825\ud558\uc2e0 \uc815\ubcf4\ub85c \uac00\uc785\ub41c \ub0b4\
 LOGN_0002=\ube44\ubc00\ubc88\ud638\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.
 LOGN_0003=\ub85c\uadf8\uc778 \uc0c1\ud0dc\uac00 \uc544\ub2d9\ub2c8\ub2e4. \ub2e4\uc2dc \ub85c\uadf8\uc778 \ud574\uc8fc\uc138\uc694.
 LOGN_0004=\ube44\ubc00\ubc88\ud638\ub97c \ubcc0\uacbd\ud55c \ub0a0\ub85c\ubd80\ud130 3\uac1c\uc6d4\uc774 \uacbd\uacfc\ub418\uc5c8\uc2b5\ub2c8\ub2e4.
+LOGN_0005=\uc811\uc18d \uac00\ub2a5\ud55c IP\uc8fc\uc18c\uac00 \uc544\ub2d9\ub2c8\ub2e4.
 
 ##\uc8fc\ubb38
 ORDER_0001=\uc8fc\ubb38\uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.

BIN
src/main/webapp/WEB-INF/lib/gagaframework-web-security-1.7.1-RELEASE.jar → src/main/webapp/WEB-INF/lib/gagaframework-web-security-1.7.2-RELEASE.jar