Skip to content
Advertisement

How to save the request body after reading it in the ServerAuthenticationConverter?

Guys! maybe someone faced the problem of getting the request body..

I am trying to friend Spring WebFlux + Security: I use SecurityConfig

JavaScript

where I set

JavaScript

for check authentication

JavaScript

I have a custom Converter (AuthDataConverter) and a custom Manager (AuthManager). When I do POST http Request I am falling in Converter: inside of the Converter – I get Headers and Body of Request:

JavaScript

and all good – AuthDataConverter gets request params and send in AuthManager:

JavaScript

But! Problem: in next step, where I am falling in Controller:

JavaScript

Advertisement

Answer

After Reactor HTTP Request Body is subscribed once, the result of next subscribe is empty. This is because Reactor sets the source of HTTP Request Body as FluxRecive, which is a dynamic publisher that publishes the message body as HTTP Request. Therefore, when the HTTP Request message body is subscribed once, all subsequent subscribes are empty. Because the body of the HTTP Request is only sent once.

For me helped this article: https://www.programmersought.com/article/47663615530/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement