티스토리 뷰

Spring Security - ArcheTecher_SecurityContextHolder Authentication

 

 

SecurityContextHolder

  • Security Context 제공, 기본적으로 ThreadLocal을 사용한다.
  • 기본 전략은 ThreadLocal 기반으로 동작한다.
  • SecurityContextHolder를 통해 SecurityContext에 접근할 수 있다.

 

SecurityContext

  • Authentication을 제공한다.

 

Authentication

  • Spring Security에서 인증을 거치고난 뒤의 사용자의 인증정보를 Principal 이라고 한다.
  • 이러한 Principal을 감싸고 있는 객체이다.
  • Printcipal 외에도 GrantedAuthorities (사용자 권한 정보) 등 다양한 정보를 가지고 있다.
  • SecurityContext 를 통해 Authentication 객체를 받아올 수 있다.

 

Principal

  • UserDetailsService에서 리턴한 객체이다.
  • UserDetails 타입
  • 인증에 성공한 사용자 정보에 해당한다.

 

GrantedAuthorities

  • ROLE_USER, ROLE_ADMIN 등 Principal이 가지고 있는 권한을 나타낸다.
  • 인증 이후 인가 및 권한을 확인할때 참조한다.

 

ThreadLocal

  • ThreadLocal은 같은 Thread 내에서 공유하는 저장소이다.
  • Parameter를 넘기지 않아도, 쓰레드 내에서 데이터를 공유 및 전달이 가능하다.

 

사용 예제

 

참조

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함