inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링 시큐리티

8) 익명사용자 인증 필터 : AnonymousAuthenticationFilter

loginPage("/login").permitAll() 오류

1245

최민종

작성한 질문수 9

0

안녕하세요
loginPage("/login").permitAll(); 라인중 permitAll() 추가할 경우 아래와같이 오류가 발생하는데요... 원인을 모르겠습니다.
무슨 문제때문인지 힌트를 얻을 수 있을까요?
 
java: 11
spring boot : 2.6.1
UserDetailsService userDetailsService;

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests()
.anyRequest().authenticated();
http
.formLogin()
.loginPage("/login").permitAll();
http
.rememberMe()
.rememberMeParameter("remember")
.tokenValiditySeconds(3600)
.userDetailsService(userDetailsService);
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-12-05 15:36:54.966 ERROR 4156 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: permitAll only works with HttpSecurity.authorizeRequests() at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.13.jar:5.3.13] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.13.jar:5.3.13] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.13.jar:5.3.13]

spring-boot java Spring Security

답변 1

1

정수원

오류내용을 보면 

permitAll only works with HttpSecurity.authorizeRequests() 이라고 되어 있습니다.

근데 작성하신 소스를 보면

http.authorizeHttpRequests() 로 시작하고 있습니다.

http.authorizeHttpRequests() 를 http.authorizeRequests() 로 변경하시면 정상 동작합니다.

그리고 확인해 보니 http.authorizeHttpRequests() 은 강의에서 사용하는 버전에서는 지원하지 않습니다.

스프링 시큐리티가 버전이 업그레이드 되면서 추가된 api 인것 같습니다.

참고하시기 바랍니다.

 

0

최민종

도움주셔서 감사합니다! :) 

시큐리티 공부 버전 질문

0

188

1

[해결 방법] MethodSecurityConfig.customMethodSecurityMetadataSource() 호출하지 않는 이슈

0

196

1

AbstractSecurityInterceptor.class.beforeInvocation()를 2번 실행하는 경우

0

185

1

강의 코드가 왜이렇게 뒤죽박죽인가요...

0

270

1

메인 페이지로 접속해도 login url로 리다이렉트가 되지 않습니다..

0

247

1

파라미터값이 넘어가지 않습니다 ....

0

381

1

security filterChain 설정 질문이 있습니다.

0

336

1

소스 부분 질문 드립니다.

0

211

2

섹션4 7번 강의 문제가 있는거 같네요.

0

351

2

파일이 수시로 이름이 바껴있네요 ㄷㄷ

0

308

1

HttpSessionSecurityContextRepository를 사용안하는 문제

0

563

2

error , exception 이 잘 안됩니다.

0

288

2

thymeleaf tag 질문합니다.

0

200

2

버전업하면서 deprecated된 것들이 너무많아요

0

482

1

spring security 패치 관련

0

442

1

모바일을 사용할때 토큰말고 세션

0

863

2

DB 연동한 인가 부분에 대한 질문입니다!

0

267

1

Ajax방식도 똑같이 Session방식을 사용하는건가요?

0

310

1

Config 파일 생성 시 질문이 있습니다.

0

233

1

강사님 몇일동안 구글 검색만 100개 했는데도 이유를 모르겠습니다..

1

440

2

403 에러 뜹니다.

0

816

2

login_proc의 존재에 대한 간략한 설명입니다

0

279

1

top.html에 로그인 링크를 만들어서 로그인을 해봤습니다

0

289

2

안녕하세요. DB에 저장될 때 이해 안 가는 값이 있어서 질문드립니다!

0

193

1