SecurityContext란?

이승언·2025년 3월 31일
  1. 인증된 사용자 정보인 PrincipalAuthentication에서 관리하고

  2. AuthenticationSecurityContext(Authentication 객체가 저장되는 보관소)가 관리하고

  3. SecurityContextSecurityContextHolder(SecurityContext 저장을 위한 ThreadLocal 를 갖고 있는 객체)가 관리한다.

즉 SecurityContextHolder란 Authentication을 담고 있는 Holder라고 정의할 수 있다.


기본적으로 ThreadLocal을 사용한다.

  • ThreadLocal : 한 쓰레드 내에서 사용하는 공용 저장소

  • 즉 ThreadLocal을 사용해서 Authentication을 한 쓰레드 내에서 공유가 가능

  • 쓰레드가 달라지면 제대로 된 인증 정보를 가져올 수 없다.

profile
꾸준히 점진적으로 성장하는 인간

0개의 댓글