spring security restful controller check user code example
Example: check authorities spring
@GetMapping("/users")
public String getUsers() {
UserDetails details = userDetailsService.loadUserByUsername("mike");
if (details != null && details.getAuthorities().stream()
.anyMatch(a -> a.getAuthority().equals("ADMIN"))) {
// ...
}
}