Compare commits
No commits in common. "e321c6e45eaa8d2d1026e4a8b7ffe3f476498d8d" and "57ce1a5dabf8bca1ac522e988930793bbd1d64bf" have entirely different histories.
e321c6e45e
...
57ce1a5dab
|
|
@ -67,7 +67,7 @@ function UserInfoModal({savedInfo, reloadFunction}){
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(resp) => {
|
(resp) => {
|
||||||
|
debugger
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
package com.dbnt.kcscbackend.admin.logs.entity;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import org.hibernate.annotations.DynamicInsert;
|
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Entity
|
|
||||||
@NoArgsConstructor
|
|
||||||
@DynamicInsert
|
|
||||||
@DynamicUpdate
|
|
||||||
@Table(name = "th_login_log")
|
|
||||||
public class ThLoginLog {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "ll_seq")
|
|
||||||
private Long llSeq;
|
|
||||||
|
|
||||||
@Column(name = "user_id")
|
|
||||||
private String userId;
|
|
||||||
|
|
||||||
@Column(name = "access_dt")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime accessDt;
|
|
||||||
|
|
||||||
@Column(name = "ip_address")
|
|
||||||
private String ipAddress;
|
|
||||||
|
|
||||||
@Column(name = "session_id")
|
|
||||||
private String sessionId;
|
|
||||||
|
|
||||||
@Column(name = "access_type")
|
|
||||||
private String accessType;
|
|
||||||
}
|
|
||||||
|
|
@ -21,20 +21,19 @@ import java.time.LocalDate;
|
||||||
@Table(name = "tn_daily_user_log")
|
@Table(name = "tn_daily_user_log")
|
||||||
public class TnDailyUserLog {
|
public class TnDailyUserLog {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "dul_seq")
|
@Column(name = "dul_seq")
|
||||||
private Long dulSeq;
|
private Long dulSeq;
|
||||||
|
|
||||||
|
@Column(name = "log_cnt")
|
||||||
|
private Long logCnt;
|
||||||
|
|
||||||
@Column(name = "log_dt")
|
@Column(name = "log_dt")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate logDt;
|
private LocalDate logDt;
|
||||||
|
|
||||||
@Column(name = "log_cnt")
|
|
||||||
private Long logCnt;
|
|
||||||
|
|
||||||
@Column(name = "mobile_cnt")
|
@Column(name = "mobile_cnt")
|
||||||
private Long mobileCnt;
|
private Integer mobileCnt;
|
||||||
|
|
||||||
@Column(name = "pc_cnt")
|
@Column(name = "pc_cnt")
|
||||||
private Long pcCnt;
|
private Integer pcCnt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface PrivacyLogsRepository extends JpaRepository<ThPrivacyLog, Long> {
|
public interface PrivacyLogsRepository extends JpaRepository<ThPrivacyLog, String> {
|
||||||
List<ThPrivacyLog> findAllByOrderByUplSeqDesc();
|
List<ThPrivacyLog> findAllByOrderByUplSeqDesc();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
package com.dbnt.kcscbackend.admin.logs.repository;
|
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.entity.ThLoginLog;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ThLoginLogRepository extends JpaRepository<ThLoginLog, Long> {
|
|
||||||
|
|
||||||
List<ThLoginLog> findByUserIdAndAccessDtAfter(String userId, LocalDateTime accessDt);
|
|
||||||
}
|
|
||||||
|
|
@ -5,9 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface UserLogsRepository extends JpaRepository<TnDailyUserLog, Long> {
|
public interface UserLogsRepository extends JpaRepository<TnDailyUserLog, Long> {
|
||||||
|
|
||||||
|
|
@ -23,5 +21,5 @@ public interface UserLogsRepository extends JpaRepository<TnDailyUserLog, Long>
|
||||||
+ "ORDER BY log_dt asc", nativeQuery = true)
|
+ "ORDER BY log_dt asc", nativeQuery = true)
|
||||||
List<Object[]> selectCountUser(@Param("startDate") String startDate, @Param("endDate") String endDate);
|
List<Object[]> selectCountUser(@Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||||
|
|
||||||
Optional<TnDailyUserConnLog> findByLogDt(LocalDate logDt);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,13 @@
|
||||||
package com.dbnt.kcscbackend.admin.logs.service;
|
package com.dbnt.kcscbackend.admin.logs.service;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.entity.ThLoginLog;
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.entity.ThPrivacyLog;
|
import com.dbnt.kcscbackend.admin.logs.entity.ThPrivacyLog;
|
||||||
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserConnLog;
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.repository.PrivacyLogsRepository;
|
import com.dbnt.kcscbackend.admin.logs.repository.PrivacyLogsRepository;
|
||||||
import com.dbnt.kcscbackend.admin.logs.repository.ThLoginLogRepository;
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.repository.UserLogsRepository;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -22,8 +17,6 @@ import java.util.Map;
|
||||||
public class AdminLogsService extends EgovAbstractServiceImpl {
|
public class AdminLogsService extends EgovAbstractServiceImpl {
|
||||||
|
|
||||||
private final PrivacyLogsRepository privacyLogsRepository;
|
private final PrivacyLogsRepository privacyLogsRepository;
|
||||||
private final ThLoginLogRepository loginLogRepository;
|
|
||||||
private final UserLogsRepository userLogsRepository;
|
|
||||||
|
|
||||||
public Map<String, Object> selectPrivacyList() {
|
public Map<String, Object> selectPrivacyList() {
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
@ -53,44 +46,4 @@ public class AdminLogsService extends EgovAbstractServiceImpl {
|
||||||
log.setTargetUserId(targetUserId);
|
log.setTargetUserId(targetUserId);
|
||||||
privacyLogsRepository.save(log);
|
privacyLogsRepository.save(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void insertLoginLog(String userId, String ipAddress, String accessToken, String accessType, String webType){
|
|
||||||
ThLoginLog loginLog = new ThLoginLog();
|
|
||||||
loginLog.setUserId(userId);
|
|
||||||
loginLog.setIpAddress(ipAddress);
|
|
||||||
loginLog.setSessionId(accessToken);
|
|
||||||
loginLog.setAccessType(accessType);
|
|
||||||
loginLog.setAccessDt(LocalDateTime.now());
|
|
||||||
loginLogRepository.save(loginLog);
|
|
||||||
|
|
||||||
// 로그인 기록이면 tn_daily_yser_log 카운트 조정
|
|
||||||
if(accessType.equals("Y")){
|
|
||||||
//오늘 일자 로그 조회
|
|
||||||
TnDailyUserConnLog userConnLog = userLogsRepository.findByLogDt(LocalDate.now()).orElse(null);
|
|
||||||
if(userConnLog==null){
|
|
||||||
userConnLog = new TnDailyUserConnLog();
|
|
||||||
userConnLog.setLogDt(LocalDate.now());
|
|
||||||
userConnLog.setLogCnt(0L);
|
|
||||||
userConnLog.setMobileCnt(0L);
|
|
||||||
userConnLog.setPcCnt(0L);
|
|
||||||
}
|
|
||||||
if(webType.equals("PC")){
|
|
||||||
userConnLog.setPcCnt(userConnLog.getPcCnt()+1);
|
|
||||||
}else{
|
|
||||||
userConnLog.setMobileCnt(userConnLog.getMobileCnt()+1);
|
|
||||||
}
|
|
||||||
//같은 일자 로그인 기록 확인
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
now = now.minusHours(now.getHour());
|
|
||||||
now = now.minusMinutes(now.getMinute());
|
|
||||||
now = now.minusSeconds(now.getSecond());
|
|
||||||
List<ThLoginLog> todayLoginLog = loginLogRepository.findByUserIdAndAccessDtAfter(userId, now);
|
|
||||||
if(todayLoginLog.size()==0){
|
|
||||||
userConnLog.setLogCnt(userConnLog.getLogCnt()+1);
|
|
||||||
}
|
|
||||||
userLogsRepository.save(userConnLog);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.dbnt.kcscbackend.config.security;
|
package com.dbnt.kcscbackend.config.security;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
|
||||||
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.egov.EgovProperties;
|
import com.dbnt.kcscbackend.config.egov.EgovProperties;
|
||||||
|
|
@ -32,7 +31,6 @@ import java.util.List;
|
||||||
public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||||
|
|
||||||
private final EgovJwtTokenUtil jwtTokenUtil;
|
private final EgovJwtTokenUtil jwtTokenUtil;
|
||||||
private final AdminLogsService adminLogsService;
|
|
||||||
private RequestCache requestCache = new HttpSessionRequestCache();
|
private RequestCache requestCache = new HttpSessionRequestCache();
|
||||||
|
|
||||||
private static final List<String> adminIpList = Arrays.asList(EgovProperties.getProperty("Globals.admin.allow-ip").split(","));
|
private static final List<String> adminIpList = Arrays.asList(EgovProperties.getProperty("Globals.admin.allow-ip").split(","));
|
||||||
|
|
@ -55,14 +53,12 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
|
||||||
securityUser = (UserInfo) principal;
|
securityUser = (UserInfo) principal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String accessIp = ClientUtils.getRemoteIP(request);
|
|
||||||
|
|
||||||
// application/json(ajax) 요청일 경우 아래의 처리!
|
// application/json(ajax) 요청일 경우 아래의 처리!
|
||||||
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
|
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
|
||||||
MediaType jsonMimeType = MediaType.APPLICATION_JSON;
|
MediaType jsonMimeType = MediaType.APPLICATION_JSON;
|
||||||
HashMap<String, Object> resultMap = new HashMap<>();
|
HashMap<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
||||||
/*if(securityUser.getUserId().equals("admin") && !adminIpList.contains(accessIp)){
|
/*if(securityUser.getUserId().equals("admin") && !adminIpList.contains(ClientUtils.getRemoteIP(request))){
|
||||||
resultMap.put("resultCode", ResponseCode.FAILED.getCode());
|
resultMap.put("resultCode", ResponseCode.FAILED.getCode());
|
||||||
resultMap.put("resultMessage", "관리자 계정은 지정된 아이피에서만 접속할 수 있습니다.\n필요한 경우 관리자에게 요청하십시오.\n접속자 아이피: "+ClientUtils.getRemoteIP(request));
|
resultMap.put("resultMessage", "관리자 계정은 지정된 아이피에서만 접속할 수 있습니다.\n필요한 경우 관리자에게 요청하십시오.\n접속자 아이피: "+ClientUtils.getRemoteIP(request));
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -82,9 +78,6 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
|
||||||
resultMap.put("accessToken", accessToken);
|
resultMap.put("accessToken", accessToken);
|
||||||
resultMap.put("refreshToken", refreshToken);
|
resultMap.put("refreshToken", refreshToken);
|
||||||
|
|
||||||
//로그인 로그 기록
|
|
||||||
adminLogsService.insertLoginLog(securityUser.getUserId(), accessIp, accessToken, "Y", ClientUtils.getWebType(request));
|
|
||||||
|
|
||||||
if (jsonConverter.canWrite(resultMap.getClass(), jsonMimeType)) {
|
if (jsonConverter.canWrite(resultMap.getClass(), jsonMimeType)) {
|
||||||
jsonConverter.write(resultMap, jsonMimeType, new ServletServerHttpResponse(response));
|
jsonConverter.write(resultMap, jsonMimeType, new ServletServerHttpResponse(response));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.dbnt.kcscbackend.config.security;
|
package com.dbnt.kcscbackend.config.security;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
|
||||||
import com.dbnt.kcscbackend.config.jwt.EgovJwtTokenUtil;
|
import com.dbnt.kcscbackend.config.jwt.EgovJwtTokenUtil;
|
||||||
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationEntryPoint;
|
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationEntryPoint;
|
||||||
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationFilter;
|
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationFilter;
|
||||||
|
|
@ -50,7 +49,6 @@ public class SecurityConfig {
|
||||||
private UserDetailsService loginService;
|
private UserDetailsService loginService;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final EgovJwtTokenUtil egovJwtTokenUtil;
|
private final EgovJwtTokenUtil egovJwtTokenUtil;
|
||||||
private final AdminLogsService adminLogsService;
|
|
||||||
|
|
||||||
//Http Methpd : Get 인증예외 List
|
//Http Methpd : Get 인증예외 List
|
||||||
private String[] AUTH_GET_WHITELIST = {
|
private String[] AUTH_GET_WHITELIST = {
|
||||||
|
|
@ -147,7 +145,7 @@ public class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JsonAuthenticationFilter jsonUsernamePasswordAuthenticationFilter() {
|
public JsonAuthenticationFilter jsonUsernamePasswordAuthenticationFilter() {
|
||||||
JsonAuthenticationFilter jsonAuthenticationFilter = new JsonAuthenticationFilter(objectMapper, new CustomUrlAuthenticationSuccessHandler(egovJwtTokenUtil, adminLogsService), loginFailureHandler());
|
JsonAuthenticationFilter jsonAuthenticationFilter = new JsonAuthenticationFilter(objectMapper, new CustomUrlAuthenticationSuccessHandler(egovJwtTokenUtil), loginFailureHandler());
|
||||||
jsonAuthenticationFilter.setAuthenticationManager(authenticationManager());
|
jsonAuthenticationFilter.setAuthenticationManager(authenticationManager());
|
||||||
return jsonAuthenticationFilter;
|
return jsonAuthenticationFilter;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,20 +29,4 @@ public class ClientUtils {
|
||||||
|
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getWebType(HttpServletRequest request) {
|
|
||||||
String filter = "iphone|ipod|android|windows ce|blackberry|symbian|windows phone|webos|opera mini|opera mobi|polaris|iemobile|lgtelecom|nokia|sonyericsson|lg|samsung";
|
|
||||||
String filters[] = filter.split("\\|");
|
|
||||||
String webType = "";
|
|
||||||
|
|
||||||
for(String tmp : filters){
|
|
||||||
if (request.getHeader("User-Agent").toLowerCase().contains(tmp)) {
|
|
||||||
webType = "MOBILE";
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
webType = "PC";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return webType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue