You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
894 B

3 years ago
  1. package ru.digitalbanana.demoresourceserver.config;
  2. import org.springframework.context.annotation.Configuration;
  3. import org.springframework.http.HttpMethod;
  4. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  5. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  6. @Configuration
  7. public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  8. @Override
  9. protected void configure(HttpSecurity http) throws Exception {
  10. http.cors()
  11. .and()
  12. .authorizeRequests()
  13. .antMatchers(HttpMethod.GET, "/userinfo", "/user/**")
  14. .authenticated()
  15. // .hasAuthority("SCOPE_web-api")
  16. .anyRequest()
  17. .authenticated()
  18. .and()
  19. .oauth2ResourceServer()
  20. .jwt();
  21. }
  22. }