@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() //정적 리소스 접근 허용
.anyRequest().permitAll()
).formLogin(login -> login
.loginPage("/user/login")
.loginProcessingUrl("/"));
return http.build();
}
(사용자 로그인 성공 후, JWT가 클라이언트에게 전달되는 과정)
클라이언트가 서버측에 로그인 인증 요청(Username/Password)
로그인 인증을 담당하는 Security Filter(JwtAuthenticationFilter)가 클라이언트의 로그인 인증 정보를 수신 후 AuthenticationManager에게 인증처리를 위임
AuthenticationManagerk CustomUserDetailsService에게 사용자의 UserDetails조회를 위임
CustomUserDetailsService가 사용자의 Credential을 DB에서 조회한 후, AuthenticationManager에게 사용자의 UserDetails 전달
AuthenticationManager가 로그인 인증정보와 UserDetails의 정보를 비교해 인증 처리
JWT 생성후, 클라이언트의 응답으로 전달