TokenInterceptor.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.ydtech.components;
  2. import cn.dev33.satoken.interceptor.SaInterceptor;
  3. import cn.dev33.satoken.router.SaRouter;
  4. import cn.dev33.satoken.stp.StpUtil;
  5. import org.springframework.stereotype.Component;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. @Component
  9. public class TokenInterceptor {
  10. public static SaInterceptor tokenInterceptor() {
  11. List<String> notMatchList = new ArrayList<>();
  12. notMatchList.add("/favicon.ico");//@TODO 静态资源应该不请求后台 需要确认
  13. notMatchList.add("/captcha.jpg**"); // 验证码
  14. notMatchList.add("/login");
  15. notMatchList.add("/sendMsg");
  16. notMatchList.add("/loginByPhone");
  17. notMatchList.add("/esmUserInternalcheck/userRegist");
  18. notMatchList.add("/dict/**"); //字典
  19. //中煤
  20. notMatchList.add("/zm/Underwriting"); //自动核保回调
  21. notMatchList.add("/zm/ArtificialUnderwriting"); //人工核保回调
  22. notMatchList.add("/order/zhongMeiApi/underwritingCallback");
  23. notMatchList.add("/order/zhongMeiApi/auditCallback");
  24. //永安
  25. notMatchList.add("/order/yongAn/updatePolicy"); // 支付回调
  26. notMatchList.add("/order/yongAn/getMessage"); // 获取短信消息
  27. // swagger
  28. notMatchList.add("/doc.html");
  29. notMatchList.add("/webjars/**");
  30. notMatchList.add("/swagger-resources");
  31. notMatchList.add("/v2/**");
  32. return new SaInterceptor(handler -> {
  33. // 指定一条 match 规则
  34. SaRouter
  35. .match("/**") // 拦截的 path 列表,可以写多个 */
  36. .notMatch(notMatchList) // 排除掉的 path 列表,可以写多个
  37. .check(r -> StpUtil.checkLogin());
  38. });
  39. }
  40. }