1) 모든 URL에 대해서 인증을 요구한다.
2) 로그인 폼을 생성한다.
3) 기초적인 폼에 대해서 사용자 이름과 비밀번호를 요구한다.
4) 사용자에 대한 로그아웃 기능도 있다.
5) CSRF(Cross Site Request Forgery) 공격을 방어한다.
6) Session Fixsation을 방어한다.
7) 요청 헤드 보안
8) Servlet API 제공
Spring Security 는 위와 같이 인증/인가에 필요한 많은 기능들을 제공하기 때문에 개발자들의 입장에서 저러한 기능들을 일일이 다 구현할 필요 없이 Spring Security 를 적용시킴으로써 보안적인 측면도 개선하고 개발 시간을 절약할 수 있기 때문입니다.
Spring Security 와 Filter
SecurityFilterChain
AbstractAuthenticationProcessingFilter
UsernamePasswordAuthenticationFilter
SecurityContextHolder
Authentication
현재 인증된 사용자를 나타내며 SecurityContext 에서 가져올 수 있다.
Principal : User의 식별자로, User Id, Email과 같은 정보를 담고 있는 객체입니다.
Credentials : Password와 같은 중요한 정보로, 유출방지를 위해 보통 인증된 이후에는 삭제됩니다.
Authorities : 권한 정보로, 보통 Role 혹은 Scope(어떤 걸 수행할수 있는지)로 설정을 합니다.
// Authentication 설정 예시코드
SecurityContext context = SecurityContextHolder.createEmptyContext();
Authentication authentication = new UsernamePasswordAuthenticationToken(principal, credentials, authorities);
context.setAuthentication(authentication);
SecurityContextHolder.setContext(context);
UsernamePasswordAuthenticationTokend은 Authentication을 implements한 AbstractAuthenticationToken의 하위 클래스로, 인증객체를 만드는데 사용된다. SecurityContext는 이 Authentication 객체를 담는 Container 역할을하고, SecurityContextHolder는 다시 SecurityContext 를 관리하는 역할을 한다고 볼 수 있습니다.

UserDetailsService
UserDetails
