Answers for "check authorities spring"

0

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"))) {
        // ...
    }
}
Posted by: Guest on December-20-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language