|
@@ -3,6 +3,7 @@ package com.style24.admin.support.security;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.authentication.AuthenticationProvider;
|
|
import org.springframework.security.authentication.AuthenticationProvider;
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
@@ -13,13 +14,13 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import com.style24.admin.biz.service.TsaLoginService;
|
|
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.core.support.message.TscMessageByLocale;
|
|
|
import com.style24.persistence.domain.User;
|
|
import com.style24.persistence.domain.User;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import com.gagaframework.web.security.GagaPasswordEncoder;
|
|
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"));
|
|
throw new BadCredentialsException(message.getMessage("LOGN_0005"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- log.info("encoded password: {}", GagaCryptoUtil.encryptSha512(passwd));
|
|
|
|
|
boolean isMatch = passwordEncoder.matches(passwd, loginInfo.getPasswd());
|
|
boolean isMatch = passwordEncoder.matches(passwd, loginInfo.getPasswd());
|
|
|
log.info("isMatch: {}", isMatch);
|
|
log.info("isMatch: {}", isMatch);
|
|
|
|
|
|
|
@@ -70,6 +70,11 @@ public class TsaAuthenticationProvider implements AuthenticationProvider {
|
|
|
throw new BadCredentialsException(message.getMessage("LOGN_0002"));
|
|
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<>();
|
|
List<SimpleGrantedAuthority> authorities = new ArrayList<>();
|
|
|
authorities.add(new SimpleGrantedAuthority(loginInfo.getRoleCd()));
|
|
authorities.add(new SimpleGrantedAuthority(loginInfo.getRoleCd()));
|
|
@@ -87,4 +92,30 @@ public class TsaAuthenticationProvider implements AuthenticationProvider {
|
|
|
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
|
|
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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|