shjung 2 năm trước cách đây
mục cha
commit
b6063ca1d1

+ 2 - 2
src/main/java/com/its/op/security/WebController.java

@@ -30,10 +30,10 @@ public class WebController {
      */
     @GetMapping({"", "/", "/index.do", "/login.do"})
     public ModelAndView getLogin(HttpServletRequest request, HttpServletResponse response) {
-        log.info("getLogin1: {}", request);
+        //log.info("getLogin1: {}", request);
         Authentication auth = SecurityContextHolder.getContext().getAuthentication();
         if(auth != null) {
-            log.info("getLogin2: {}", auth);
+            //log.info("getLogin2: {}", auth);
             return new ModelAndView("redirect:" + WebConstants.DEFAULT_URI);
             //new SecurityContextLogoutHandler().logout(request, response, auth);
         }

+ 4 - 4
src/main/java/com/its/op/security/WebHttpSessionListener.java

@@ -39,9 +39,9 @@ public class WebHttpSessionListener implements HttpSessionListener {
                 session.setMaxInactiveInterval(WebConstants.MAX_INACTIVE_SESSION_TIMEOUT);
                 log.info("Session Created: User: {}, {}", userInfr.getUserId(), userInfr.getOperSystId());
             }
-            log.error("Session Created: {}, {}, {}", creationTime, lastAccessTime, session.getMaxInactiveInterval());
+            log.info("Session Created: {}, {}, {}", creationTime, lastAccessTime, session.getMaxInactiveInterval());
         }
-        log.error("Session Created: {}", httpSessionEvent.getSession().getMaxInactiveInterval());
+        log.info("Session Created: {}", httpSessionEvent.getSession().getMaxInactiveInterval());
     }
 
     @Override
@@ -65,11 +65,11 @@ public class WebHttpSessionListener implements HttpSessionListener {
                 log.info("Session Destroyed: User: {}, {}, {}, {}", userInfr.getUserId(), userInfr.getOperSystId(), userInfr.getLoginHms(), userInfr.getLogoutHms());
             }
             else {
-                log.error("Session Destroyed: {}, {}, {}", creationTime, lastAccessTime, session.getMaxInactiveInterval());
+                log.info("Session Destroyed: {}, {}, {}", creationTime, lastAccessTime, session.getMaxInactiveInterval());
             }
         }
         else {
-            log.error("Session Destroyed: {}", httpSessionEvent);
+            log.info("Session Destroyed: {}", httpSessionEvent);
         }
     }
 

+ 27 - 28
src/main/java/com/its/op/security/WebSecurityConfig.java

@@ -78,28 +78,28 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
 
         try {
             http.csrf().disable();  // REST API 호출 유효하게(POST...)
-            http
-                    .authorizeRequests()
-                    // SWAGGER 권한 설정
-                    .antMatchers("/swagger-ui.html", "/swagger/**", "/swagger-resources/**", "/webjars/**", "/v2/api-docs").permitAll()
-                    // 웹소켓 권한 설정하지
-                    .antMatchers("/ws/**").permitAll()
-                    .antMatchers("/api/resource/**").permitAll()
-                    .antMatchers("/api/reload/**").permitAll()
-                    .antMatchers("/api/test/**").permitAll()
-                    .antMatchers("/api/manual/**").permitAll()
-//                    .antMatchers("/api/**").permitAll()   // 로그인 하지 않을 경우 주석해제
-                    // 지도 URI 권한 설정하지
-                    .antMatchers("/MAPDATA/**").permitAll()
-                    .antMatchers("/download/**").permitAll()
-                    // 페이지 권한 설정
-                    .antMatchers("/application/wall/**", "/wall/**").permitAll()
-                    .antMatchers("/application/facility/**", "/facility/**").permitAll()
-                    .antMatchers("/application/dashboard/**", "/dashboard/**").permitAll()
-                    .antMatchers("/application/login/**").permitAll()
-                    .antMatchers("/api/auth/**").permitAll()
-                    .anyRequest().authenticated()
-                    .and()
+            http.authorizeRequests()
+                // SWAGGER 권한 설정
+                .antMatchers("/swagger-ui.html", "/swagger/**", "/swagger-resources/**", "/webjars/**", "/v2/api-docs").permitAll()
+                // 웹소켓 권한 설정하지
+                .antMatchers("/ws/**").permitAll()
+                .antMatchers("/api/resource/**").permitAll()
+                .antMatchers("/api/reload/**").permitAll()
+                .antMatchers("/api/test/**").permitAll()
+                .antMatchers("/api/manual/**").permitAll()
+//                .antMatchers("/api/**").permitAll()   // 로그인 하지 않을 경우 주석해제
+                // 지도 URI 권한 설정하지
+                .antMatchers("/MAPDATA/**").permitAll()
+                .antMatchers("/download/**").permitAll()
+                // 페이지 권한 설정
+                .antMatchers("/application/wall/**", "/wall/**").permitAll()
+                .antMatchers("/application/facility/**", "/facility/**").permitAll()
+                .antMatchers("/application/dashboard/**", "/dashboard/**").permitAll()
+                .antMatchers("/application/login/**").permitAll()
+                .antMatchers("/application/manual/**").permitAll()
+                .antMatchers("/api/auth/**").permitAll()
+                .anyRequest().authenticated()
+                .and()
                     .formLogin()
                     .loginPage(loginPage)
                     .loginProcessingUrl("/api/auth/login.do")
@@ -107,9 +107,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     .usernameParameter("username")
                     .passwordParameter("password")
                     .successHandler(this.webLoginSuccessHandler)
-                    .failureHandler(this.webLoginFailureHandler)
-                    .permitAll()
-                    .and()
+                    .failureHandler(this.webLoginFailureHandler).permitAll()
+                .and()
                     .logout()
                     .addLogoutHandler(new UserLogoutHandler()).permitAll()
                     .logoutSuccessUrl(loginPage).permitAll()
@@ -117,7 +116,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     .deleteCookies("JSESSIONID")
                     .deleteCookies(WebConstants.USER_UUID)
                     .deleteCookies(WebConstants.USER_TIME)
-                    .and()
+                .and()
                     .sessionManagement()
                     .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)   // 스프링 시큐리티가 필요 시 생성 (default)
                     // 인증에 성공할 때 마다 세션 ID나 세션을 변경해서 발급해줌으로써
@@ -127,8 +126,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     // none            : 아무 동작 안함
                     // migrateSession  : 새로운 세션을 생성해서 전달 (속성값 유지)
                     // newSession      : 새로운 세션 전달 (속성값 유지 안됨)
-                    .maximumSessions(20)                        // 최대 허용 가능 세션 수, -1인 경우 무제한 세션 허용
-                    .maxSessionsPreventsLogin(true)             // 동시 로그인 차단, false 인 경우 기존 세션 만료(default)
+                    .maximumSessions(20)            // 최대 허용 가능 세션 수, -1인 경우 무제한 세션 허용(같은 ID로 접속가능한 세션의 갯수)
+                    .maxSessionsPreventsLogin(true) // false 인 경우 기존 사용자가 접속했고 새로 접속하는 사용자가 있을 경우 기존 사용자는 접속을 끊고 새로 들어오는 사용자를 받는다.(default)
                     .expiredUrl(loginPage)          // 세션이 만료된 경우 이동 할 페이지
                     .sessionRegistry(sessionRegistry())
             ;