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 Type
    Method
    Description
    @Nullable io.micronaut.http.HttpResponse<?>
    filterRequest(io.micronaut.http.HttpRequest<?> request)
    Evaluates the request against the configured Fetch Metadata rules.
    void
    filterResponse(io.micronaut.http.MutableHttpResponse<?> response)
    Adds the Fetch Metadata request headers to the Vary response header, so that a shared cache does not serve a response allowed for one kind of request to another.
    int
    Runs Fetch Metadata isolation before authentication and authorization filters.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getOrder

      public int getOrder()
      Runs Fetch Metadata isolation before authentication and authorization filters.
      Specified by:
      getOrder in interface io.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.ALLOWED or FetchMetadataRuleResult.REJECTED decides the result. The filter denies the request when every rule returns FetchMetadataRuleResult.UNKNOWN.

      Parameters:
      request - the request to evaluate
      Returns:
      null to 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 the Vary response 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