본문 바로가기

spring/security4

WebSecurity.ignoring()을 알아보자 백선장님 인강에서 보면 ignoring 하는 방법과 ignoring 된 요청은 시큐리티 필터 목록 (Filters) 갯수가 "0"임을 확인할 수 있었다. ignoring() 내부와 어떻게 필터 목록이 0개가 되는지 살펴보고 싶어졌다. # ignoring() 정적인 요청은 시큐리티 설정에서 WebSecurity.ignoring()을 이용하여 필터 적용을 제외할 수 있다. ignoring()외에 다른 방법들도 존재하는데, 어떤 것들이 있는지 살펴보자. # 요청 제외 방법 사진에 나와있는 WebSecurity.ignoring()이 제공해주는 제외 방법이 requestMatchers 외에도 다른 방법들이 존재하는데, ignoring 내부를 들어가보면 다음과 같다. IgnoredRequestConfigurer 를.. 2021. 5. 30.
AutenticationManger, ProviderManger, AuthenticationProvider를 알아보자. 이번엔 인증처리를 하는 주요 객체를 간단하게 살펴보자. # AuthenticationManager AuthenticationManager is the API that defines how Spring Security’s Filters perform authentication. The Authentication that is returned is then set on the SecurityContextHolder by the controller (i.e. Spring Security’s Filterss) that invoked the AuthenticationManager. If you are not integrating with Spring Security’s Filterss you can set the.. 2021. 5. 24.
SecurityContext 와 Authentication 내부 속으로 이전 포스팅에서는 SecurityContext를 가지고 있는 SecurityContextHolder 내부를 살펴보았다. 이번에는 SecurityContext와 Authentication의 내부를 살펴보자. # SecurityContext javadoc에 설명된 내용을 해석해보자. 현재 실행 중인 쓰레드와 연관된 최소한의 보안 정보를 정의하는 인터페이스이다. SecurityContext는 SecurityContextHolder에 저장된다. SecurityContext를 구현한 구현체는 SecurityContextImpl 하나밖에 없다. (SecurityContextImpl 내부를 보면 Authentication을 가지고 있는 것 외에는 크게 중요한 게 없다.) 다음으로 Authentication 내부를 살.. 2021. 5. 17.
SecurityContextHolder의 내부를 파헤쳐보자 인프런 백선장님의 강의를 보면서 내부가 좀 더 궁금해졌다. # SecurityContextHolder란 ? 우선 강의에서 설명해주시는 정의는 다음과 같다. 1. 인증된 사용자 정보인 `Principal`을 `Authentication`에서 관리하고 `Authentication`을 `SecurityContext`가 관리하고 `SecurityContext`는 `SecurityContextHolder`가 관리한다. 2. 기본적으로 ThreadLocal을 사용한다. ThreadLocal : 한 쓰레드 내에서 사용하는 공용 저장소 즉 ThreadLocal을 사용해서 `Authentication`을 한 쓰레드 내에서 공유가 가능하다. 쓰레드가 달라지면 제대로 된 인증 정보를 가져올 수 없다. 즉 SecurityCo.. 2021. 5. 14.