Spring Security를 처음 배울 때 가장 먼저 마주치는 기능이 바로 로그인이다. 우리가 별다른 설정을 안 해도 /login 경로로 username과 password를 보내면 마법처럼 로그인이 된다. 이 마법을 부리는 주인공이 바로 UsernamePasswordAuthenticationFilter다. 하지만 요즘은 JSP보다 React/Vue와 통신하는 REST API 서버를 많이 만든다. 이때 "어? JSON으로 아이디/비번 보냈는데 로그인이 안 돼요!" 라며 당황하는 경우가 많다. 범인은 바로 이 필터의 태생적 한계 때문이다. 오늘은 이 필터의 동작 원리와, JSON 로그인을 위해 커스터마이징하는 방법을 정리해본다. Spring Security의 필터 체인 중에서 "아이디와 비밀번호를 사용하는 폼(Form) 기반 인증"을 처리하는 필터다.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with import org.springframework.util.Stream
Contact import org.springframework.util.Stream, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack