Spring Boot 3.1 & Spring Security 6: Security Config 최적화 리팩토링 (12편)
·
Spring/Spring Security
이번에는 필요없는 필터는 없애고 최적화를 진행하기 위해 Security Config를 리팩토링 했다. 1. SecurityConfig 리팩토링 앞의 게시글을 확인해보면 작성한 코드가 있기에 변경된 메서드만 설명하겠다. 일단 나는 ssl(서버 사이드 랜더링)이기 때문에 에러페이지, 메인페이지, 회원가입, 로그인, 정적 리소스는 모두 접근을 허가해줬다. 여기서 특히 바뀐건 addFilterBefore() 이것이다. jwtAuthorizationFilter 다음 바로 customAuthenticationFilter로 가도록 했다. @Bean public SecurityFilterChain filterChain( HttpSecurity http, CustomAuthenticationFilter customAut..
Spring Boot 3.1 & Spring Security 6: 로그인 프로세스 및 JWT 토큰 동작 설명 (10편)
·
Spring/Spring Security
지금까지 만든 시큐리티의 동작을 설명하겠다. 1. 로그인 과정 로그인 페이지 접근: 사용자는 웹 브라우저에서 로그인 페이지(/login)에 접근한다. 로그인 페이지에는 사용자 이름과 비밀번호를 입력할 수 있는 폼이 있다. 로그인 요청: 사용자가 자신의 사용자 이름과 비밀번호를 입력하고 "Login" 버튼을 클릭하면, AJAX 요청을 통해 서버에 로그인 요청(/user/login)이 전송된다. 인증 필터 처리: CustomAuthenticationFilter는 로그인 요청을 가로챈다. 이 필터는 UsernamePasswordAuthenticationFilter를 확장하여 구현되었다. 요청에서 사용자 이름과 비밀번호를 추출하여 UsernamePasswordAuthenticationToken 객체를 생성한다...