Added methods to add filter relatively in ServerHttpSecurity
Addition of two new methods addFilterBefore and addFilterAfter in ServerHttpSecurity to allow addition of WebFilter before and after of specified order Fixes: gh-6138
This commit is contained in:
@@ -288,6 +288,32 @@ public class ServerHttpSecurity {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link WebFilter} before specific position.
|
||||
* @param webFilter the {@link WebFilter} to add
|
||||
* @param order the place before which to insert the {@link WebFilter}
|
||||
* @return the {@link ServerHttpSecurity} to continue configuring
|
||||
* @since 5.2.0
|
||||
* @author Ankur Pathak
|
||||
*/
|
||||
public ServerHttpSecurity addFilterBefore(WebFilter webFilter, SecurityWebFiltersOrder order) {
|
||||
this.webFilters.add(new OrderedWebFilter(webFilter, order.getOrder() - 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link WebFilter} after specific position.
|
||||
* @param webFilter the {@link WebFilter} to add
|
||||
* @param order the place after which to insert the {@link WebFilter}
|
||||
* @return the {@link ServerHttpSecurity} to continue configuring
|
||||
* @since 5.2.0
|
||||
* @author Ankur Pathak
|
||||
*/
|
||||
public ServerHttpSecurity addFilterAfter(WebFilter webFilter, SecurityWebFiltersOrder order) {
|
||||
this.webFilters.add(new OrderedWebFilter(webFilter, order.getOrder() + 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ServerExchangeMatcher that determines which requests apply to this HttpSecurity instance.
|
||||
* @return the ServerExchangeMatcher that determines which requests apply to this HttpSecurity instance.
|
||||
|
||||
Reference in New Issue
Block a user