최종 변경 : 2023.11.08


세션 현재 사용자 아이디

SecurityContextHolder.getContext().getAuthentication().getName();

세션 현재 사용자 role

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
Iterator<? extends GrantedAuthority> iter = authorities.iterator();
GrantedAuthority auth = iter.next();
String role = auth.getAuthority();