Advertisement
vana_shimko

Untitled

Apr 26th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. @Override
  2. public void configure(HttpSecurity http) throws Exception {
  3. http
  4. .authorizeRequests()
  5. .antMatchers("/api/users/register").permitAll()
  6.  
  7. .antMatchers(HttpMethod.GET, "/api/courses/**").authenticated()
  8. .antMatchers( "/api/courses/**").hasAuthority(User.Role.ADMIN.name())
  9.  
  10. .antMatchers(HttpMethod.GET, "/api/lessons/**").authenticated()
  11. .antMatchers(HttpMethod.PUT, "/api/lessons/**").hasAuthority(User.Role.TEACHER.name())
  12. .antMatchers("/api/lessons/**").hasAuthority(User.Role.ADMIN.name())
  13.  
  14. .antMatchers(HttpMethod.GET,"/api/hometasks/solutions/marks/**").authenticated()
  15. .antMatchers("/api/hometasks/solutions/marks/**").hasAnyAuthority(User.Role.ADMIN.name(), User.Role.TEACHER.name())
  16.  
  17. .antMatchers(HttpMethod.GET, "/api/users/**").authenticated()
  18. .antMatchers(HttpMethod.PUT, "/api/users/**").authenticated()
  19. .antMatchers("/api/users/logout", "/api/users/password/change").authenticated()
  20. .antMatchers( "/api/users/**").hasAuthority(User.Role.ADMIN.name())
  21.  
  22. .antMatchers(HttpMethod.GET, "/api/hometasks/solutions/**").authenticated()
  23. .antMatchers(HttpMethod.POST, "/api/hometasks/solutions/**").hasAnyAuthority(User.Role.STUDENT.name(), User.Role.ADMIN.name())
  24. .antMatchers("/api/hometasks/solutions").hasAuthority(User.Role.ADMIN.name())
  25.  
  26. .antMatchers(HttpMethod.GET, "/api/courses/feedbacks/**").authenticated()
  27. .antMatchers(HttpMethod.PUT, "/api/courses/feedbacks/**").hasAnyAuthority(User.Role.STUDENT.name(), User.Role.ADMIN.name())
  28. .antMatchers(HttpMethod.POST, "/api/courses/feedbacks/**").hasAnyAuthority(User.Role.STUDENT.name(), User.Role.ADMIN.name())
  29. .antMatchers(HttpMethod.DELETE, "/api/courses/feedbacks/**").hasAnyAuthority(User.Role.STUDENT.name(), User.Role.ADMIN.name())
  30.  
  31. .antMatchers(HttpMethod.GET, "/api/teachers/**").hasAnyAuthority(User.Role.TEACHER.name(), User.Role.ADMIN.name())
  32.  
  33. .antMatchers("/api/**").authenticated()
  34. .anyRequest().permitAll();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement