카테고리 없음
[spring] How to get Authentication
한상규
2022. 6. 16. 18:57
https://www.baeldung.com/get-user-in-spring-security
Retrieve User Information in Spring Security | Baeldung
How to get the currently logged in user with Spring Security.
www.baeldung.com
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Authentication을 얻어오고 싶을 때가 있다.
그 때는 SecurityContextHolder.getContext() 에 접근해서 가져오면된다.
controller 레벨에서는 arguments에 Authentication authentication를 달아주면 알아서 값이 authentication에 들어온다.