AuthWebMvcConfig.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.gihon.component.web.config;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.core.Ordered;
  5. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  6. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  7. import com.gihon.component.properties.GihonCommonProperties;
  8. import com.gihon.component.web.auth.AuthTokenInterceptor;
  9. import com.gihon.component.web.auth.AuthenticationInterceptor;
  10. /**
  11. * 非Security
  12. *
  13. * @author baihe
  14. *
  15. */
  16. @Configuration
  17. public class AuthWebMvcConfig implements WebMvcConfigurer {
  18. @Autowired
  19. private AuthTokenInterceptor authTokenInterceptor;
  20. @Autowired
  21. private AuthenticationInterceptor authenticationInterceptor;
  22. @Autowired
  23. private GihonCommonProperties gihonCommonProperties;
  24. @Override
  25. public void addInterceptors(InterceptorRegistry registry) {
  26. // 认证
  27. registry.addInterceptor(authTokenInterceptor).order(Ordered.HIGHEST_PRECEDENCE).addPathPatterns("/**");
  28. // 权限
  29. registry.addInterceptor(authenticationInterceptor).order(Ordered.HIGHEST_PRECEDENCE + 1).addPathPatterns("/**")
  30. .excludePathPatterns(gihonCommonProperties.getWhiteUrlList());
  31. }
  32. }