스프링 기반 애플리케이션의 인증(Authentication)과 인가(Authorization)를 담당하는 보안 프레임워크. 강력한 확장성으로 요구사항에 맞춰 쉽게 커스터마이징할 수 있다.
요청 → 다층 보안 필터 통과 → 컨트롤러
| 필터 | 역할 요약 |
|---|---|
| SecurityContextPersistenceFilter | SecurityContext 로딩/저장 |
| LogoutFilter | 로그아웃 처리 후 즉시 종료 |
| UsernamePasswordAuthenticationFilter | 폼 로그인 인증 수행 |
| DefaultLoginPageGeneratingFilter | 기본 로그인 페이지 제공 |
| AnonymousAuthenticationFilter | 비인증 사용자에 익명 권한 부여 |
| SessionManagementFilter | 세션 타임아웃/동시 세션/세션 고정 방어 |
| ExceptionTranslationFilter | 인증/인가 예외 → 401/403 처리 또는 리다이렉트 |
| FilterSecurityInterceptor | 자원 접근 권한 최종 판정 |
핵심 포인트
UsernamePasswordAuthenticationFilterFilterSecurityInterceptor
UsernamePasswordAuthenticationToken 생성loadUserByUsername() 호출UserDetails 반환 → 인증 검증SecurityContextHolder에 Authentication 저장 → 이후 어디서든 조회 가능
| 구분 | 세션(Session/Cookie) | 토큰(Token) |
|---|---|---|
| 저장 위치 | 서버(세션 저장소) | 클라이언트(로컬스토리지/쿠키 등) |
| 장점 | 구현 간단, 서버에서 즉시 무효화 가능 | 서버 확장 용이, 무상태(Stateless) |
| 단점 | 확장 시 부담(Sticky/Clustering/외부 세션 저장소 필요) | 탈취 시 위험(민감정보 금지, 만료·재발급 전략 필수) |
| 확장 전략 | Sticky, Clustering, 외부 세션 저장소(예: Redis) | 짧은 Access + 긴 Refresh 조합, 재발급 플로우 |
인증 서버가 발급하는 서명된 토큰. 클라이언트가 요청마다 전송하고 서버는 서명 검증만으로 신뢰할 수 있다.

운영 팁
UserDetailsService와 PasswordEncoder가 올바로 연동되는가Authentication → Provider → UserDetailsService 흐름으로 처리