shinsunyoung/springboot-developer

[Chapter 08] 회원가입후 로그인시 교재의 화면으로 이동하지 않고 "Whitelabel Error Page" 가 표시됨

Closed this issue · 1 comments

안녕하세요
교재의 챕터 08장을 공부 중에 궁금한 사항이 있어서 문의드립니다.
에러의 내용 및 자세한 동작은 아래와 같습니다.

  1. 회원가입 프로세스 진행: 정상
  2. 회원 로그인 진행: 교재의 화면이 나오지 않고 첨부 파일처럼 "Whitelabel Error Page" 로 이동합니다.
    코드에 어디에도 "continue" 로 이동하는 것이 없는 거 같이서 이해가 안되어 문의 드립니다.

제가 작업한 소스는 아래와 같으며 (제가 비교 검토한 바로는 현재 예제로 올려 놓으신 소스와 같고, 올려놓은신 코드도 동일한 에러가 발생합니다. 버전문제는 아닌거 같습니다. ㅠㅠ)
https://github.com/colinkim/springboot-dev/tree/chapter-08/springboot-dev
에러는 첨부파일 처럼 발생하네요
스크린샷 2024-05-23 오후 4 03 43
감사합니다.

안녕하세요. WebSecurityConfig.java 파일에서 filterChain(HttpSecurity http) 부분에서 authorizeHttpRequests를 authorizeRequests로 변경해야 합니다.

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        return http
                .**authorizeRequests**(auth -> auth
                        .requestMatchers(
                                new AntPathRequestMatcher("/login"),
                                new AntPathRequestMatcher("/signup"),
                                new AntPathRequestMatcher("/user")
                        ).permitAll()
                        .anyRequest().authenticated())
                .formLogin(formLogin -> formLogin
                        .loginPage("/login")
                        .defaultSuccessUrl("/articles")
                )
                .logout(logout -> logout
                        .logoutSuccessUrl("/login")
                        .invalidateHttpSession(true)
                )
                .csrf(AbstractHttpConfigurer::disable)
                .build();
    }