Spring에서 제공해주는 인증(Authentication)과 인가(Authorization)에 대한 처리를 위임하는 별도의 프레임워크이다.
Spring Security는 인증과 인가에 대한 부분을 Filter의 흐름에 따라 처리한다.
Spring Security는 보안과 관련하여 체계적으로 많은 옵션을 제공해주기 때문에 개발자 입장에서는 일일이 보안 관련 로직을 작성하지 않아도 된다는 장점이 존재한다.
인증
- 해당 사용자가 본인이 맞는지를 확인하는 절차
인가
- 인증된 사용자가 요청된 자원에 접근가능한가를 결정하는 절차

클라이언트로부터 로그인 정보와 함께 인증 요청을 하면 AuthenticationFilter에서 인증 및 권한 부여의 목적으로 일련의 필터를 거치게 된다.
로그인이 이미 되어있는 상태
이미 Http Session에 Authentication 객체가 저장되어 있어 Authentication Manager에서 authentication()메서드를 호출하지 않고 Security Context Holder에서 Authentication 객체를 가져와 인증 후 곧바로 클라이언트의 요청을 수행
시큐리티에서 제공하는 유저 인증 관련 필터
유저의 인증 요청에서 Authentication Filter를 통해 유저의 이름과 패스워드를 추출한다.
추출된 정보를 기반으로 인증 토큰(UsernamePasswordAuthentication Token)이 생성된다.
생성된 토큰은 Authentication Manager의 authentication() 함수를 통해 Provider Manager로 넘어간다.
UsernamePasswordAuthentication Token 객체 생성 후 Authentication Manager의 인증 메서드를 호출하는데 사용된다.
Authentication Provider는 특정 인증을 수행하며 사용자의 자격 증명을 확인하고 사용자를 인증한다. 인증에 성공하면 인증된 Authentication 객체를 반환한다.
DaoAuthentication Provider
유저 이름과 비밀번호를 사용한 인증 처리
JwtAuthentication Provider
JWT를 사용한 인증 처리
UserDetailService에 Authentication 객체를 넘겨준다.
UserDetailService는 DB에서 사용자의 정보를 토대로 검색하고 해당 데이터를 UserDetails 객체에 매핑시켜 반환한다.
Authentication Providers는 UserDetail 객체를 받아 유저 정보를 비교한다.
성공 시 AuthenticationSuccessHAndle을 실패 시 AuthenticationFailtureHandle을 실행한다.
인증이 완료되면 Principal, Credentials, Authorities, Authenticated를 설정한다.
Authentication Manager는 Authentication 객체를 관련 Authentication Filter로 반환한다.
SecurityContextHolder는 세션 영역에 있는 Security Context에 Authentication 객체를 저장한다.