mirror of https://gitee.com/stylefeng/guns
【拦截器】更新黑白名单校验拦截器
parent
f96673ac20
commit
7830c7a42c
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.guns.config.web;
|
||||
|
||||
import cn.stylefeng.guns.core.error.CustomErrorAttributes;
|
||||
import cn.stylefeng.guns.core.security.BlackWhiteInterceptor;
|
||||
import cn.stylefeng.guns.core.security.TokenAndPermissionInterceptor;
|
||||
import cn.stylefeng.roses.kernel.wrapper.field.jackson.CustomJacksonIntrospector;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
@ -28,6 +29,9 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
@Resource
|
||||
private TokenAndPermissionInterceptor tokenAndPermissionInterceptor;
|
||||
|
||||
@Resource
|
||||
private BlackWhiteInterceptor blackWhiteInterceptor;
|
||||
|
||||
/**
|
||||
* 重写系统的默认错误提示
|
||||
*
|
||||
|
@ -62,7 +66,8 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(tokenAndPermissionInterceptor);
|
||||
registry.addInterceptor(blackWhiteInterceptor).order(100);
|
||||
registry.addInterceptor(tokenAndPermissionInterceptor).order(200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package cn.stylefeng.guns.core.security;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import cn.stylefeng.roses.kernel.security.blackwhite.BlackWhiteValidateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 黑白名单的web拦截器·
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2024/7/11 10:11
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BlackWhiteInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private BlackWhiteValidateService blackWhiteValidateService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
// 校验黑白名单
|
||||
blackWhiteValidateService.totalValidate(HttpServletUtil.getRequestClientIp(request));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue