Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. @Override
  2. protected void configure(HttpSecurity http) throws Exception {
  3.  
  4. ...
  5.  
  6. http.authorizeRequests()
  7. .requestMatchers(getMatcherForAuthority1Urls())
  8. .hasAuthority("AUTHORITY1")
  9. .and().authorizeRequests()
  10. .requestMatchers(getMatcherForAuthority2Urls())
  11. .hasAuthority("AUTHORITY1")
  12. .and().authorizeRequests()
  13. .requestMatchers(getMatcherForAuthorities1and2Urls())
  14. .hasAnyAuthority("AUTHORITY1", "AUTHORITY1");
  15.  
  16. http.authorizeRequests()
  17. .regexMatchers(REGEX_PATTERN_URLS_THAT_NEED_AUTHORISATION).authenticated()
  18. .accessDecisionManager(myAccessDecisionManager());
  19.  
  20. http.authorizeRequests()
  21. .antMatchers(LOGIN_URL).permitAll();
  22. }
  23.  
  24. @Bean
  25. public AccessDecisionManager myAccessDecisionManager() {
  26. List<AccessDecisionVoter<? extends Object>> decisionVoters
  27. = Arrays.asList(
  28. new WebExpressionVoter(), // votes for authorities
  29. myAccessVoter); // my custom voter
  30.  
  31. return new UnanimousBased(decisionVoters);
  32. }
  33.  
  34. http.authorizeRequests().anyRequest().authenticated();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement