spring security1 [Spring Security] 로그인한 사용자의 아이디와 권한(Role) 가져오기 로그인한 사용자 아이디String id = SecurityContextHolder.getContext().getAuthentication().getName(); 로그인한 사용자의 권한 구하기Authentication authentication = SecurityContextHolder.getContext().getAuthentication();Collection authorities = authentication.getAuthorities();Iterator iter = authorities.iterator();GrantedAuthority auth = iter.next();String role = auth.getAuthority(); 위 방식으로 로그인한 사용자가 쓴 글인지 일치여부를 확인할 수 있.. 2024. 5. 20. 이전 1 다음