728x90
- Spring Security는 Spring MVC 인수에 대한 현재 Authentication.getPrincipal()을 자동으로 해결 할 수 있는 AuthenticationPrincipalArgumentResolver를 제공
- Spring MVC 에서 @AuthenticationPrincipal을 메서드 인수에 선언하게 되면 Spring Security와 독립적으로 사용 가능
- @AuthenticationPrincipal 어노테이션이 메소드 호출 전 Authentication으로 부터 customer 객체를 principal에서 꺼내서 customUser의 인자로 전달해주는 역할
@AuthenticationPrincipal(expression=”표현식”)
- Principal 객체 내부에서 특정 필드나 메서드에 접근하고자 할 때 사용할 수 있으며 사용자 세부 정보가 Principal 내부의 중첩된 객체에 있는 경우 유용
- 표현식을 사용 시 UserDetails의 속성(멤버 필드, username, password, authorities 등)에 바로 접근하여 값을 반환
- 표현식을 사용하지 않으면 UserDetails 객체 자체를 가지고 옴
@AuthenticationPrincipal 메타 주석
- @AuthenticationPrincipal을 자체 주석으로 메타 주석화하여Spring Security에 대한 종속성을 제거 가능
728x90
'Language > Spring Security' 카테고리의 다른 글
다중 보안 설정 (0) | 2024.08.03 |
---|---|
Spring MVC 비동기 통합 - WebAsyncManagerIntergrationFilter (0) | 2024.08.03 |
Servlet API 통합 - SecurityContextHoladerAwareRequestFilter (0) | 2024.08.03 |
인가 이벤트 - Authorization Events (0) | 2024.08.03 |
인증 이벤트 - AuthenticationEventPublisher 활용 (0) | 2024.08.02 |