inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링과 JPA 기반 웹 애플리케이션 개발

회원 가입 뷰

지원중단

해결된 질문

2210

고래돌

작성한 질문수 3

1

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
public class SecurityConfig extends WebSecurityConfigurerAdapter
에서
WebSecurityConfigurerAdapter
 
이게 지원중단이라떠서 더이상 진행이 불가능한데 어떻게 해결할 수 있나요?
 
 
 
 
 

spring spring-boot java JPA thymeleaf

답변 2

3

ssodo

스프링 시큐리티 5.7.x 부터 WebSecurityConfigurerAdapter 는 Deprecated 되었습니다.

찾아보니 상황에 따라 SecurityFilterChain 과 WebSecurityCustomizer 를 빈으로 등록해 사용하는 방식을 권장하는 것 같아 저는 아래 코드처럼 사용하고 있습니다.

 

https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter

@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfig {

private final AccountService accountService;
private final DataSource dataSource;

/**
* Spring Security 5.7.x 부터 WebSecurityConfigurerAdapter Deprecated.
* -> SecurityFilterChain, WebSecurityCustomizer 를 상황에 따라 빈으로 등록해 사용한다.
*/
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http.authorizeRequests()
.mvcMatchers("/", "/login", "/sign-up", "/check-email", "/check-email-token",
"/email-login", "/check-email-login", "login-link", "/profile/*").permitAll()
.mvcMatchers(HttpMethod.GET, "/profile/*").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll()
.and()
.logout().logoutSuccessUrl("/")
.and()
.rememberMe().userDetailsService(accountService).tokenRepository(tokenRepository())
.and().build();
}

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring()
.mvcMatchers("/node_modules/**")
.requestMatchers(PathRequest.toStaticResources().atCommonLocations());
}
}

0

백기선

감사합니다. WebSecurityConfigurerAdapter 문서에서도 이 방법을 권장하고 있습니다.

https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.html

0

스프링

저도 궁금합니다!

Study 개설하는 로직에 대해서 궁금점이 있습니다.

0

56

1

앱 재시작 후 회원가입

0

104

1

app.host 관련 질문이 있습니다

0

98

1

강의 버전 정보

0

126

1

event, study 참조

0

222

2

비밀번호 변경 로직 질문있습니다.

0

136

1

프로필 수정 처리 merge 질문입니다.

0

108

1

회원가입 성공 후 redirect이동시 권한 질문

0

497

3

HtmlEmailService 개발하다 생긴 의문입니다

0

251

2

postgreSql 연결하여 JPA 를 통해 테이블 생성시 ZONE 테이블 생성에서 에러가 납니다

0

432

2

수업질문 [긴급] 로그인안되는 문제 말씀해주시는 부분 반영해서 최종 질문드립니다

0

264

2

[긴급-재업로드]수업질문 로그인 안 되는 문제

0

237

1

[긴급] 로그인해도 네비게이션 바가 안 바뀌고 있습니다!! 로그인이 안 됩니다 도와주세요

0

278

1

cropper 오류 문제로 질문드립니다..

0

289

2

authentication관련 질문...

0

498

2

모임참가 취소 할때 로직 질문

0

351

3

안녕하세요 기선님 질문이있습니다..

0

230

1

HTML코드 및 강의 중간자료들

0

680

3

springSecurity

0

525

2

버전 질문입니다.

0

304

1

부트스트랩, css

0

357

2

영속성 컨텍스트 질문

0

251

2

다시 강의를 보니 드는생각..

0

355

2

5:50에 나오는 HTML코드는 어디서 찾을 수 있나여?

0

316

1