티스토리 뷰
스프링 시큐리티 설정 작업도중
WebSecurityConfigurerAdapter가 Deprecated되어 아예 사용할 수 없었다.
나는 스프링부트3.1.4 버전을 사용했고 스프링 부트3.0 이상부터는 스프링시큐리티6.0 으로 자동 적용된다고 한다.
그리고 스프링시큐리티 6버전부터 WebSecurityConfigurerAdapter가 지원되지않는것이다!!
WebSecurityConfigurerAdapter를 사용하면서 config를 오버라이드 해서 작성하였는데,
이젠 bean으로 등록하도록 작성하면된다.
수정 전
@Override
protected void configure(HttpSecurity http) throws Exception {
// http 시큐리티 빌더
http.cors()
.and()
.csrf()
.disable()
.httpBasic()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/", "/auth/**").permitAll()
.anyRequest()
.authenticated();
http.addFilterAfter(
jwtAuthenticationFilter,
CorsFilter.class
);
}
WebSecurityConfigurerAdapter 를 상속받는 클래스 안에 오버라이드하여 configure 함수를 작성하였다.
수정 후
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// http 시큐리티 빌더
http
.cors().and()
.csrf().disable()
.httpBasic().disable()
.sessionManagement(c -> c.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeRequests()
.requestMatchers("/", "/auth/**").permitAll()
.anyRequest()
.authenticated();
http.addFilterAfter(
jwtAuthenticationFilter,
CorsFilter.class
);
return http.build();
}
이 클래스는 아무것도 상속받지않고
filterChain함수를 빈으로 등록하였다.
WebSecurityConfigurerAdapter를 상속받지 않고 filterChain을 빈으로 등록하면서 http시큐리티 빌더 작성부분도
조금씩 달라진 것 같았다. 정답일진 모르겠으나 나는 우선 해결했다..
더 공부해서 친절한 설명을 드리겠습니다...
'웹 개발' 카테고리의 다른 글
| [React.js, 스프링부트, AWS로 배우는 웹개발101] (0) | 2023.09.08 |
|---|
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- springboot
- 알고리즘
- Spring
- 네스트
- 자바
- Nest
- 인텔리제이
- 프론트엔드
- programmers
- Java
- 스프링시큐리티
- HashMap
- 코딩
- intellij
- 웹개발
- codingtest
- coding
- NestJS
- 코딩테스트
- 시간복잡도
- 프로그래머스
- 코딩공부
- Hashtable
- 스프링부트
- 코테
- 자바공부
- 문자열출력
- 자료구조
- hash
- Annotation
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함