spring security architecture

최성원·2023년 8월 1일

백엔드 데브코스

목록 보기
3/6

필터 알아보기

  • AnonymousAuthenticationFilter
  • ExceptionTranslationFilter

AnonymousAuthenticationFilter

공식 문서 설명

Detects if there is no Authentication object in the SecurityContextHolder, and populates it with one if needed.

해당 필터에 요청이 도착할 때까지 사용자의 인증 정보가 null 이면 AnonymousUser 라는 인증 정보로 변환해주는 역할을 한다

  • key, principal, authorities 3가지 정보를 넘겨준다

ExceptionTranslationFilter

공식 문서 설명

Handles any AccessDeniedException and AuthenticationException thrown within the filter chain.

Java에서의 Exception 과 HTTP Response 를 연결해주는 역할을 하기 때문에 꼭 필요하다

  • AuthenticationException 이 발생했을 경우
    • filter 가 authenticationEntryPoint 를 실행함
    • -> 인증실패에 대해 처리할 수 있게 해줌
  • AccessDeniedException 이 발생했을 경우
    • user 가 anonymous user 인 경우
      • authenticationEntryPoint 가 실행 됨
      • -> 예외를 일으킨 요청을 caching 하고 로그인 페이지로 보내버림
    • anonymous user 가 아닌 경우 or rememberMe 로 인증된 사용자인 경우
      • AccessDeniedHandler 에게 처리를 위임함
      • -> 기본적으로 AccessDeniedHandlerImpl 구현체를 사용함
      • -> 예외를 일으킨 요청을 caching 하고 인증 가능한 로그인 페이지로 보내버림

Remember Me 인증 처리 과정 알아보기

  • Security Filter for Remember Me
  • Authentication 인터페이스 구현 클래스 for Remember Me
  • AuthenticationProvier 인터페이스 구현 클래스 for Remember Me
  • Authentication -> RememberMeAuthenticationToken
  • AuthenticationProvider -> RememberMeAuthenticationProvider

암호화 알아보기

  • 대칭 키 암호화
  • RSA 암호화

참고

AnonymousAuthenticationFilter 공식 문서
Spring Security - Web Application Security reference
ExceptionTranslationFilter 공식 문서

profile
안녕하세요 백엔드 개발자입니다

1개의 댓글

comment-user-thumbnail
2023년 8월 1일

이런 유용한 정보를 나눠주셔서 감사합니다.

답글 달기