|
@@ -71,53 +71,47 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
@Override
|
|
|
protected void configure(HttpSecurity http) {
|
|
|
|
|
|
- // URL 권한 설정
|
|
|
- //setAntMatchers(http, "ROLE_");
|
|
|
String loginPage = WebConstants.LOGIN_PAGE_URI; // 로그인 할 경우 URL
|
|
|
// String loginPage = WebConstants.DEFAULT_URI; // 로그인 하지 않을 경우 URL
|
|
|
|
|
|
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("/application/manual/**").permitAll()
|
|
|
- .antMatchers("/api/auth/**").permitAll()
|
|
|
- .anyRequest().authenticated()
|
|
|
- .and()
|
|
|
- .formLogin()
|
|
|
+ // SWAGGER 권한 설정
|
|
|
+ .antMatchers("/swagger-ui.html", "/swagger/**", "/swagger-resources/**", "/webjars/**", "/v2/api-docs").permitAll()
|
|
|
+ // 웹소켓 권한 설정하지
|
|
|
+ .antMatchers("/ws/**").permitAll()
|
|
|
+ .antMatchers("/api/dashboard/**").permitAll()
|
|
|
+ .antMatchers("/api/auth/**").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()
|
|
|
+ .anyRequest().authenticated();
|
|
|
+ http.formLogin()
|
|
|
.loginPage(loginPage)
|
|
|
.loginProcessingUrl("/api/auth/login.do")
|
|
|
.defaultSuccessUrl(WebConstants.DEFAULT_URI, true)
|
|
|
.usernameParameter("username")
|
|
|
.passwordParameter("password")
|
|
|
.successHandler(this.webLoginSuccessHandler)
|
|
|
- .failureHandler(this.webLoginFailureHandler).permitAll()
|
|
|
- .and()
|
|
|
- .logout()
|
|
|
- .addLogoutHandler(new UserLogoutHandler()).permitAll()
|
|
|
- .logoutSuccessUrl(loginPage).permitAll()
|
|
|
+ .failureHandler(this.webLoginFailureHandler);
|
|
|
+ http.logout()
|
|
|
+ .addLogoutHandler(new UserLogoutHandler())
|
|
|
+ .logoutSuccessUrl(loginPage)
|
|
|
.invalidateHttpSession(true)
|
|
|
- .deleteCookies("JSESSIONID")
|
|
|
- .deleteCookies(WebConstants.USER_UUID)
|
|
|
- .deleteCookies(WebConstants.USER_TIME)
|
|
|
- .and()
|
|
|
- .sessionManagement()
|
|
|
+ .deleteCookies(WebConstants.JSESSIONID, WebConstants.USER_UUID, WebConstants.USER_TIME);
|
|
|
+ http.sessionManagement()
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) // 스프링 시큐리티가 필요 시 생성 (default)
|
|
|
// 인증에 성공할 때 마다 세션 ID나 세션을 변경해서 발급해줌으로써
|
|
|
// 세션을 중간에서 가로채더라도 해당 세션이 유효하지 않게 하는 기능
|
|
@@ -129,8 +123,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
.maximumSessions(20) // 최대 허용 가능 세션 수, -1인 경우 무제한 세션 허용(같은 ID로 접속가능한 세션의 갯수)
|
|
|
.maxSessionsPreventsLogin(true) // false 인 경우 기존 사용자가 접속했고 새로 접속하는 사용자가 있을 경우 기존 사용자는 접속을 끊고 새로 들어오는 사용자를 받는다.(default)
|
|
|
.expiredUrl(loginPage) // 세션이 만료된 경우 이동 할 페이지
|
|
|
- .sessionRegistry(sessionRegistry())
|
|
|
- ;
|
|
|
+ .sessionRegistry(sessionRegistry());
|
|
|
} catch (IOException e) {
|
|
|
// FOR KISA Secure Coding pass
|
|
|
log.error("{configure: IOException}");
|
|
@@ -206,8 +199,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
// url, 권한 정보를 넣는다.
|
|
|
try {
|
|
|
http.authorizeRequests()
|
|
|
- .antMatchers(url)
|
|
|
- .hasAnyAuthority(roles);
|
|
|
+ .antMatchers(url)
|
|
|
+ .hasAnyAuthority(roles);
|
|
|
} catch (IOException ie) {
|
|
|
// FOR KISA Secure Coding pass
|
|
|
log.error("setAntMatchers: IOException");
|