Skip to content

Commit c26c64c

Browse files
committed
非 DEBUG 模式不允许外部操作 APIJSON 配置表
1 parent 2ce8ad1 commit c26c64c

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎APIJSONORM/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.Tencent</groupId>
77
<artifactId>APIJSON</artifactId>
8-
<version>8.1.6</version>
8+
<version>8.1.7</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONORM</name>

‎APIJSONORM/src/main/java/apijson/Log.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Log {
2121

2222
public static String LEVEL = LEVEL_WARN;
2323

24-
public static final String VERSION = "8.1.6";
24+
public static final String VERSION = "8.1.7";
2525
public static final String KEY_SYSTEM_INFO_DIVIDER = "\n---|-----APIJSON SYSTEM INFO-----|---\n";
2626

2727
public static final String OS_NAME;

‎APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public abstract class AbstractVerifier<T, M extends Map<String, Object>, L exten
108108
// <TableName, <METHOD, allowRoles>>
109109
// <User, <GET, [OWNER, ADMIN]>>
110110
@NotNull
111-
public static Map<String, Map<RequestMethod, String[]>> SYSTEM_ACCESS_MAP;
111+
public static Map<String, Map<RequestMethod, String[]>> SYSTEM_ACCESS_MAP; // TODO 改名为 CONFIG_ACCESS_MAP ?
112112
@NotNull
113113
public static Map<String, Map<RequestMethod, String[]>> ACCESS_MAP;
114114
@NotNull
@@ -319,6 +319,10 @@ public void verifyAllowRole(SQLConfig<T, M, L> config, String table, RequestMeth
319319
role = config == null ? UNKNOWN : config.getRole();
320320
}
321321

322+
if (Log.DEBUG == false && SYSTEM_ACCESS_MAP.get(table) != null) {
323+
throw new IllegalAccessException(table + " 不允许 " + role + " 用户的 " + method.name() + " 请求!");
324+
}
325+
322326
Map<RequestMethod, String[]> map = ACCESS_MAP.get(table);
323327

324328
if (map == null || Arrays.asList(map.get(method)).contains(role) == false) {

0 commit comments

Comments
 (0)