refactor: 将防火墙路由拦截的 path 配置改为 List<String> 数据类型

This commit is contained in:
click33 2025-03-08 00:26:29 +08:00
parent d853d61bf6
commit 4b02b5bb28
3 changed files with 14 additions and 5 deletions

View File

@ -19,6 +19,10 @@ import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.context.model.SaResponse;
import cn.dev33.satoken.exception.RequestPathInvalidException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 防火墙策略校验钩子函数请求 path 黑名单校验
*
@ -35,14 +39,15 @@ public class SaFirewallCheckHookForBlackPath implements SaFirewallCheckHook {
/**
* 请求 path 黑名单
*/
public String[] blackPaths = {};
public List<String> blackPaths = new ArrayList<>();
/**
* 重载配置
* @param paths 黑名单 path 列表
*/
public void resetConfig(String... paths) {
this.blackPaths = paths;
this.blackPaths.clear();
this.blackPaths.addAll(Arrays.asList(paths));
}
/**

View File

@ -19,6 +19,10 @@ import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.context.model.SaResponse;
import cn.dev33.satoken.exception.StopMatchException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 防火墙策略校验钩子函数请求 path 白名单放行
*
@ -35,14 +39,15 @@ public class SaFirewallCheckHookForWhitePath implements SaFirewallCheckHook {
/**
* 请求 path 白名单
*/
public String[] whitePaths = {};
public List<String> whitePaths = new ArrayList<>();
/**
* 重载配置
* @param paths 白名单 path 列表
*/
public void resetConfig(String... paths) {
this.whitePaths = paths;
this.whitePaths.clear();
this.whitePaths.addAll(Arrays.asList(paths));
}
/**

View File

@ -3,7 +3,6 @@ package com.pj.satoken;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.filter.SaServletFilter;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.plugin.SaTokenPluginForJackson;
import cn.dev33.satoken.plugin.SaTokenPluginHolder;
import cn.dev33.satoken.router.SaHttpMethod;
import cn.dev33.satoken.router.SaRouter;