未验证 提交 915647c8 编写于 作者: sinat_25235033's avatar sinat_25235033 提交者: GitHub

process authorized can not match roles when role name is upper (#65)

* bugfix: process authorized can not match roles when role name is upper.
上级 aa78cae0
......@@ -79,8 +79,6 @@ public class DefaultPathRoleMatcher implements TreePathRoleMatcher {
logger.warn("sureness - pathTreeProvider: {} provideExcludedResource is null", provider);
}
}
resources = resources.stream().map(String::toLowerCase).collect(Collectors.toSet());
root.buildTree(resources);
excludeResources = excludeResources.stream()
......@@ -110,8 +108,6 @@ public class DefaultPathRoleMatcher implements TreePathRoleMatcher {
logger.warn("sureness - pathTreeProvider: {} provideExcludedResource is null", provider);
}
}
resources = resources.stream().map(String::toLowerCase).collect(Collectors.toSet());
root.rebuildTree(resources);
excludeResources = excludeResources.stream()
......
......@@ -334,13 +334,14 @@ public class TirePathTree {
}
path = PATH_SPLIT_PATTERN.matcher(path).replaceAll("/");
// remove the first /
path = path.substring(1).toLowerCase();
path = path.substring(1);
String[] tmp = path.split("===");
if (tmp.length != PATH_NODE_NUM_3) {
return;
}
tmp[0] = tmp[0].toLowerCase();
String[] urlPac = tmp[0].split(URL_PATH_SPLIT);
String method = tmp[1];
String method = tmp[1].toLowerCase();
String supportRoles = tmp[2];
Node current = rootNode;
Node pre = current;
......
......@@ -72,9 +72,11 @@ public class TirePathTreeTest {
paths.add("/**/*.html===post===[role8]");
paths.add("/**/*.css===post===[role8]");
paths.add("/**/*.js===post===[role8]");
// lower upper roles
paths.add("/api/role/book===get===[ROLE10]");
root.buildTree(paths);
assertEquals(30, root.getResourceNum());
assertEquals(31, root.getResourceNum());
}
@Test
......@@ -120,6 +122,7 @@ public class TirePathTreeTest {
assertEquals("[role8]", root.searchPathFilterRoles("/content-ui.html===post"));
assertEquals("[role8]", root.searchPathFilterRoles("/api/user/ui.js===post"));
assertEquals("[role8]", root.searchPathFilterRoles("/node/v2/demo.css===post"));
// lower upper roles
assertEquals("[ROLE10]", root.searchPathFilterRoles("/api/role/book===get"));
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册