Class FetchMetadataFilter
java.lang.Object
io.micronaut.security.fetchmetadata.FetchMetadataFilter
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
@Requires(property="micronaut.security.fetch-metadata.filter.enabled",
notEquals="false",
defaultValue="true")
@ServerFilter("${micronaut.security.fetch-metadata.filter.pattern:/**}")
@Internal
public final class FetchMetadataFilter
extends Object
implements io.micronaut.core.order.Ordered
Server filter that enforces the configured Fetch Metadata request-isolation policy.
It also adds Sec-Fetch-Site, Sec-Fetch-Mode and Sec-Fetch-Dest to
the Vary header of the responses to the requests it evaluates, both allowed and
rejected, because those responses depend on the Fetch Metadata request headers.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescription@Nullable io.micronaut.http.HttpResponse<?> filterRequest(io.micronaut.http.HttpRequest<?> request) Evaluates the request against the configured Fetch Metadata rules.voidfilterResponse(io.micronaut.http.MutableHttpResponse<?> response) Adds the Fetch Metadata request headers to theVaryresponse header, so that a shared cache does not serve a response allowed for one kind of request to another.intgetOrder()Runs Fetch Metadata isolation before authentication and authorization filters.
-
Method Details
-
getOrder
public int getOrder()Runs Fetch Metadata isolation before authentication and authorization filters.- Specified by:
getOrderin interfaceio.micronaut.core.order.Ordered- Returns:
- an order before the main security filter
-
filterRequest
@RequestFilter public @Nullable io.micronaut.http.HttpResponse<?> filterRequest(io.micronaut.http.HttpRequest<?> request) Evaluates the request against the configured Fetch Metadata rules.The first rule that returns
FetchMetadataRuleResult.ALLOWEDorFetchMetadataRuleResult.REJECTEDdecides the result. The filter denies the request when every rule returnsFetchMetadataRuleResult.UNKNOWN.- Parameters:
request- the request to evaluate- Returns:
nullto continue processing, or a forbidden response to reject the request
-
filterResponse
@ResponseFilter public void filterResponse(io.micronaut.http.MutableHttpResponse<?> response) Adds the Fetch Metadata request headers to theVaryresponse header, so that a shared cache does not serve a response allowed for one kind of request to another.- Parameters:
response- the response to decorate
-