When using Spring Security to filter login requests, a custom filter can be blocked using @Beans, but not with @Import. Example: Redis control token timing.
Comment From: whcrow
🤣 我觉得你可以考虑提供一个复现示例
Comment From: bxqsunny
哈哈 我觉得你可以考虑提供一个复现示例
就是使用spring security登录时,生成的token之前不是不能够动态刷新token嘛,自定义个过滤器,使用redis来判断控制过期,我就自定义了一个过滤器,但是我使用时,使用@bean,会被拦截,但是使用@import时,并不会被拦截,也就是使用@import时,spring security并没有对过滤器进行拦截
Comment From: jgrandja
@bxqsunny Please translate to English.
Comment From: whcrow
哈哈 我觉得你可以考虑提供一个复现示例
就是使用spring security登录时,生成的token之前不是不能够动态刷新token嘛,自定义个过滤器,使用redis来判断控制过期,我就自定义了一个过滤器,但是我使用时,使用@bean,会被拦截,但是使用@import时,并不会被拦截,也就是使用@import时,spring security并没有对过滤器进行拦截
@Import?应该用@Component声明自定义Filter,通过@Autowired注入,之后在httpSecurity.addFilterBefore 中加入自定义过滤器。不过 spring security 5.5.0 (也就是springboot 2.5.0) 有个bug,addFilterBefore方法的第二个参数只支持内置的过滤器,自定义过滤器会报空指针,已经有pr了,等新版本发布吧
Comment From: sjohnr
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add a minimal sample that reproduces this issue if you feel this is a genuine bug.