Skip to content

Commit 214da6e

Browse files
committed
Server:防止GETS通过"[]":{"@ROLE":"ADMIN"},"Table":{},"tag":"Table"绕过权限并能批量查询
1 parent df60eb1 commit 214da6e

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/Parser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.alibaba.fastjson.JSONObject;
3131

3232
import apijson.demo.server.Verifier;
33-
import apijson.demo.server.model.BaseModel;
3433
import apijson.demo.server.model.User;
3534
import zuo.biao.apijson.JSON;
3635
import zuo.biao.apijson.JSONResponse;
@@ -177,7 +176,7 @@ public JSONObject parseResponse(JSONObject request) {
177176
if (session != null && requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) {
178177
requestObject.put(JSONRequest.KEY_VERSION, session.getAttribute(JSONRequest.KEY_VERSION));
179178
}
180-
179+
181180
requestObject = getCorrectRequest(requestMethod, requestObject);
182181
}
183182
} catch (Exception e) {
@@ -628,8 +627,9 @@ public JSONObject parseResponse(JSONRequest request) throws Exception {
628627
private JSONArray getArray(String parentPath, String name, final JSONObject request) throws Exception {
629628
Log.i(TAG, "\n\n\n getArray parentPath = " + parentPath
630629
+ "; name = " + name + "; request = " + JSON.toJSONString(request));
631-
if (RequestMethod.isGetMethod(requestMethod, true) == false) {
632-
throw new UnsupportedOperationException("key[]:{}只支持GET类方法!不允许传 " + name + ":{} !");
630+
//不能允许GETS,否则会被通过"[]":{"@role":"ADMIN"},"Table":{},"tag":"Table"绕过权限并能批量查询
631+
if (RequestMethod.isGetMethod(requestMethod, false) == false) {
632+
throw new UnsupportedOperationException("key[]:{}只支持GET方法!不允许传 " + name + ":{} !");
633633
}
634634
if (request == null || request.isEmpty()) {//jsonKey-jsonValue条件
635635
return null;

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/Structure.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ private Structure() {}
7070

7171
static final String requestString = "{\"Comment\":{\"DISALLOW\": \"id\", \"NECESSARY\": \"userId,momentId,content\"}, \"ADD\":{\"Comment:to\":{}}}";
7272
static final String responseString = "{\"User\":{\"REMOVE\": \"phone\", \"REPLACE\":{\"sex\":2}, \"ADD\":{\"name\":\"api\"}}, \"PUT\":{\"Comment:to\":{}}}";
73-
73+
/**测试
74+
* @throws Exception
75+
*/
7476
public static void test() throws Exception {
7577
JSONObject request;
7678
try {
@@ -121,6 +123,10 @@ public static void test() throws Exception {
121123

122124
}
123125

126+
127+
128+
129+
124130

125131
/**从request提取target指定的内容
126132
* @param method

0 commit comments

Comments
 (0)