authorizeExchange() configures endpoint authorization for reactive applications. It is called on ServerHttpSecurity while building a SecurityWebFilterChain bean, then combines request matchers with authorization decisions. section 17.3.1 section 17.5
Protecting one reactive endpoint
The following configuration requires authentication for GET requests to /hello while allowing all other exchanges. http.authorizeExchange(c -> c.pathMatchers(HttpMethod.GET, "/hello").authenticated().anyExchange().permitAll());
Chain an exchange matcher with an authorization rule:
- pathMatchers() groups exchanges by request path and can be paired with authenticated() or other decisions. section 17.3.1
- permitAll() allows requests without authentication, while denyAll() rejects every matching exchange. section 17.3.1
- hasRole(), hasAnyRole(), hasAuthority(), and hasAnyAuthority() apply role- or authority-based rules. section 17.3.1
- anyExchange() supplies a catch-all exchange matcher, and access() supports a custom reactive authorization decision. section 17.3.1
