ResourceServerConfig.java 1.2 KB

12345678910111213141516171819202122232425262728
  1. package com.huaxu.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/**",
  17. "/webSocket/**","/message/sendToOne","/messageTemplate/**","/messageType/**",
  18. "/order/workOrderManage/saveByAlarms",
  19. "/v2/**")
  20. .permitAll() //配置不需要身份认证的请求路径
  21. // .anyRequest().authenticated() //其他所有访问路径都需要身份认证
  22. .and()
  23. .httpBasic();
  24. }
  25. }