Guest User

Untitled

a guest
Apr 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import org.springframework.security.core.Authentication;
  2. import org.springframework.security.core.context.SecurityContextHolder;
  3. import org.springframework.web.bind.annotation.GetMapping;
  4. import org.springframework.web.bind.annotation.RestController;
  5.  
  6.  
  7. @RestController
  8. public class ExampleController {
  9.  
  10. @GetMapping("/")
  11. public Object index() {
  12. return getCurrentUser();
  13. }
  14.  
  15.  
  16. public Object getCurrentUser() {
  17. Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  18. return auth.getPrincipal();
  19. }
  20.  
  21. }
Add Comment
Please, Sign In to add comment