Closed z2z2qp closed 10 months ago
有点意外啊。看了下用的匹配代码是同一份的。你用的 solon 是什么版本?
这是我写的一个单测,没问题
public class RouteTest {
@Test
public void routingDefault() {
//Mvc 里用的 Mapping 路由记录
RoutingDefault routingDefault = new RoutingDefault("/captchaImage", MethodType.GET, null);
assert routingDefault.matches(MethodType.GET, "/captchaImage");
assert routingDefault.matches(MethodType.GET, "/captchaimage") == false;
routingDefault = new RoutingDefault("/captchaimage", MethodType.GET, null);
assert routingDefault.matches(MethodType.GET, "/captchaImage") == false;
assert routingDefault.matches(MethodType.GET, "/captchaimage");
}
@Test
public void authRuleImpl() {
//AuthRuleImpl 内用的路由规则
PathRule pathRule = new PathRule();
pathRule.exclude("/captchaImage");
assert pathRule.test("/captchaImage") == false;
assert pathRule.test("/captchaimage");
pathRule = new PathRule();
pathRule.exclude("/captchaimage");
assert pathRule.test("/captchaImage");
assert pathRule.test("/captchaimage") == false;
pathRule = new PathRule();
pathRule.include("/captchaImage");
assert pathRule.test("/captchaImage");
assert pathRule.test("/captchaimage") == false;
pathRule = new PathRule();
pathRule.include("/captchaimage");
assert pathRule.test("/captchaImage") == false;
assert pathRule.test("/captchaimage");
}
}
有点意外啊。看了下用的匹配代码是同一份的。你用的 solon 是什么版本?
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.6.3</version>
<relativePath/>
</parent>
这是我写的一个单测,没问题
public class RouteTest { @Test public void routingDefault() { //Mvc 里用的 Mapping 路由记录 RoutingDefault routingDefault = new RoutingDefault("/captchaImage", MethodType.GET, null); assert routingDefault.matches(MethodType.GET, "/captchaImage"); assert routingDefault.matches(MethodType.GET, "/captchaimage") == false; routingDefault = new RoutingDefault("/captchaimage", MethodType.GET, null); assert routingDefault.matches(MethodType.GET, "/captchaImage") == false; assert routingDefault.matches(MethodType.GET, "/captchaimage"); } @Test public void authRuleImpl() { //AuthRuleImpl 内用的路由规则 PathRule pathRule = new PathRule(); pathRule.exclude("/captchaImage"); assert pathRule.test("/captchaImage") == false; assert pathRule.test("/captchaimage"); pathRule = new PathRule(); pathRule.exclude("/captchaimage"); assert pathRule.test("/captchaImage"); assert pathRule.test("/captchaimage") == false; pathRule = new PathRule(); pathRule.include("/captchaImage"); assert pathRule.test("/captchaImage"); assert pathRule.test("/captchaimage") == false; pathRule = new PathRule(); pathRule.include("/captchaimage"); assert pathRule.test("/captchaImage") == false; assert pathRule.test("/captchaimage"); } }
你的测试我也跑了,没问题,但是请看图
方便的话你可以直接看的代码 https://gitee.com/z2z2qp/solon-flex 配置代码路径 src/main/java/com/zjb/demo/common/config/AuthConfig.java 测试代码路径 src/test/java/features/RouteTest.java
帮忙调试调试,找找真正的原因。
帮忙调试调试,找找真正的原因。
找到了
org.noear.solon.auth.impl.AuthRuleImpl#handle() 方法第一行
String path = ctx.pathNew().toLowerCase();
对此你怎么看😂
泪目。。。要不要帮忙提个 pr ?。。。基于 dev 修改,完了 pr 到 dev
新的快照片已发: 2.6.5-SNAPSHOT
发了测试版,试下:2.6.5-M1
有试过了吗?
2.6.5-SNAPSHOT 正常可用了
controller代码
AuthAdapter 部分代码
结果不符合预期提示认证失败
当把
.exclude("/captchaImage")
中的captchaImage替换成captchaimage 即.exclude("/captchaimage")
时候结果符合预期,提示操作成功这个exclude的参数是有什么只认小写么?直观感受不应该是和@Mapping中的大小写一致么?