From a631619f63ac3d8ba1f5e7ee8c4f4d3bcfe1c1eb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 6 Feb 2018 13:25:17 -0800 Subject: [PATCH] Allow subpath H2 console matching Fixes gh-11926 --- .../boot/autoconfigure/security/servlet/PathRequest.java | 3 ++- .../boot/autoconfigure/security/servlet/PathRequestTests.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/PathRequest.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/PathRequest.java index 5c4ed4d2e0..865af6cff6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/PathRequest.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/PathRequest.java @@ -70,7 +70,8 @@ public final class PathRequest { @Override protected void initialized(H2ConsoleProperties h2ConsoleProperties) { - this.delegate = new AntPathRequestMatcher(h2ConsoleProperties.getPath()); + this.delegate = new AntPathRequestMatcher( + h2ConsoleProperties.getPath() + "/**"); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/PathRequestTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/PathRequestTests.java index c35beb0f35..8aece43fc4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/PathRequestTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/PathRequestTests.java @@ -47,6 +47,7 @@ public class PathRequestTests { public void toH2ConsoleShouldMatchH2ConsolePath() { RequestMatcher matcher = PathRequest.toH2Console(); assertMatcher(matcher).matches("/h2-console"); + assertMatcher(matcher).matches("/h2-console/subpath"); assertMatcher(matcher).doesNotMatch("/js/file.js"); }