Guest User

Untitled

a guest
Jan 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. package org.arun.springoauth.department;
  2.  
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
  6. import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11.  
  12. @SpringBootApplication(exclude = {SecurityAutoConfiguration.class,
  13. UserDetailsServiceAutoConfiguration.class})
  14. public class DepartmentMicroService {
  15.  
  16. public static void main(String[] args) {
  17. SpringApplication.run(DepartmentMicroService.class, args);
  18. }
  19.  
  20. @RestController
  21. @RequestMapping("/api/departments")
  22. public static class DepartmentRestController {
  23.  
  24. @GetMapping(path = "/1")
  25. @PreAuthorize("hasAnyAuthority('ROLE_READ_DEPARTMENT')")
  26. public String getDepartment() {
  27. return "Software Product Engineering";
  28. }
  29. }
  30.  
  31. }
Add Comment
Please, Sign In to add comment