ResourceServerConfig.java 1.4 KB

123456789101112131415161718192021222324252627
  1. package com.zcxk.admin.config;
  2. import org.springframework.context.annotation.Configuration;
  3. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  4. import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
  5. import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
  6. @Configuration
  7. @EnableResourceServer
  8. public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
  9. @Override
  10. public void configure(HttpSecurity http) throws Exception {
  11. http
  12. .csrf().disable()
  13. .requestMatchers().antMatchers("/**")
  14. .and()
  15. .authorizeRequests()
  16. .antMatchers("/swagger-ui.html","/webjars/**", "/webjars/**", "/swagger-resources/**", "/v2/**","/facilities/config/**","/gis/config/**")
  17. .permitAll()
  18. .antMatchers("/system/product/findById","/system/site/findById", "/system/channel/findById", "/system/community/findById", "/system/building/findById","/system/project/findById","/system/customer/findById","/system/area/findById","/system/productCategory/getListByIds")
  19. .permitAll() //配置不需要身份认证的请求路径
  20. .anyRequest().authenticated() //其他所有访问路径都需要身份认证
  21. .and()
  22. .httpBasic();
  23. }
  24. }