WebFlux now uses ParsingPathMatcher
Fixes gh-4388
This commit is contained in:
@@ -20,10 +20,6 @@ import org.springframework.security.web.server.util.matcher.OrServerWebExchangeM
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
|
||||
|
||||
import static org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -52,8 +48,8 @@ abstract class AbstractServerWebExchangeMatcherRegistry<T> {
|
||||
*
|
||||
* @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
|
||||
*/
|
||||
public T antMatchers(HttpMethod method) {
|
||||
return antMatchers(method, new String[] { "/**" });
|
||||
public T pathMatchers(HttpMethod method) {
|
||||
return pathMatchers(method, new String[] { "/**" });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +64,8 @@ abstract class AbstractServerWebExchangeMatcherRegistry<T> {
|
||||
*
|
||||
* @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
|
||||
*/
|
||||
public T antMatchers(HttpMethod method, String... antPatterns) {
|
||||
return matcher(ServerWebExchangeMatchers.antMatchers(method, antPatterns));
|
||||
public T pathMatchers(HttpMethod method, String... antPatterns) {
|
||||
return matcher(ServerWebExchangeMatchers.pathMatchers(method, antPatterns));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,8 +78,8 @@ abstract class AbstractServerWebExchangeMatcherRegistry<T> {
|
||||
*
|
||||
* @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
|
||||
*/
|
||||
public T antMatchers(String... antPatterns) {
|
||||
return matcher(ServerWebExchangeMatchers.antMatchers(antPatterns));
|
||||
public T pathMatchers(String... antPatterns) {
|
||||
return matcher(ServerWebExchangeMatchers.pathMatchers(antPatterns));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AuthorizeExchangeBuilderTests {
|
||||
|
||||
@Test
|
||||
public void antMatchersWhenMethodAndPatternsThenDiscriminatesByMethod() {
|
||||
authorization.antMatchers(HttpMethod.POST, "/a", "/b").denyAll();
|
||||
authorization.pathMatchers(HttpMethod.POST, "/a", "/b").denyAll();
|
||||
authorization.anyExchange().permitAll();
|
||||
|
||||
WebTestClient client = buildClient();
|
||||
@@ -62,7 +62,7 @@ public class AuthorizeExchangeBuilderTests {
|
||||
|
||||
@Test
|
||||
public void antMatchersWhenPatternsThenAnyMethod() {
|
||||
authorization.antMatchers("/a", "/b").denyAll();
|
||||
authorization.pathMatchers("/a", "/b").denyAll();
|
||||
authorization.anyExchange().permitAll();
|
||||
|
||||
WebTestClient client = buildClient();
|
||||
@@ -90,19 +90,19 @@ public class AuthorizeExchangeBuilderTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void antMatchersWhenNoAccessAndAnotherMatcherThenThrowsException() {
|
||||
authorization.antMatchers("/incomplete");
|
||||
authorization.antMatchers("/throws-exception");
|
||||
authorization.pathMatchers("/incomplete");
|
||||
authorization.pathMatchers("/throws-exception");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void anyExchangeWhenFollowedByMatcherThenThrowsException() {
|
||||
authorization.anyExchange().denyAll();
|
||||
authorization.antMatchers("/never-reached");
|
||||
authorization.pathMatchers("/never-reached");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void buildWhenMatcherDefinedWithNoAccessThenThrowsException() {
|
||||
authorization.antMatchers("/incomplete");
|
||||
authorization.pathMatchers("/incomplete");
|
||||
authorization.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user