Description
According to the Webflux documentation it is allowed to use the return type ResponseEntity<Mono<T>>
Neither
AuthorizationManagerBeforeReactiveMethodInterceptor nor AuthorizationManagerAfterReactiveMethodInterceptor support this.
Using a method signature with the described return type causes an java.lang.IllegalStateException
like
java.lang.IllegalStateException: The returnType class org.springframework.http.ResponseEntity on public org.springframework.http.ResponseEntity example.ExampleController.getSomething() must return an instance of org.reactivestreams.Publisher (for example, a Mono or Flux) in order to support Reactor Context
at org.springframework.util.Assert.state(Assert.java:97)
Maybe a little bit of context:
We're using a code generator which produces such method signatures causing the exception whenever the return type is a list of something.
fun getSomething(): ResponseEntity<Flow<SomeDTO>>
We also found a workaround by adjusting the generator-based template but this is rather really just a workaround hence this ticket.
To Reproduce
Use simple project with spring-security 6.x and have @EnableReactiveMethodSecurity
configured.
Add @PreAuthorize
to a controller method with the return type ResponseEntity<Mono<T>>
with T being some arbitrary DTO class.
Run the server, call the endpoint and you should see the mentioned exception.
Expected behavior
@EnableReactiveMethodSecurity
should allow all valid return types defined for Webflux
Sample
Don't have one yet.