Is there a way for custom AuthenticationProvider t...
# ktor
d
Is there a way for custom AuthenticationProvider to access the body of the request (for hash computation)?
I found the plugin DoubleReceive, but I would rather avoid it. Is there perhaps some hook deeper/earlier in the pipepiline I could use to calculate the hash and pass it into 'call.attributes' for the latter stages?
a
Do you want to calculate hash of a request based on its body too?
d
What do you mean based on its body?
If the request has a body, I need to calculate its md5 digest so I could use this value as part of Hmac calculation
a
The problem is that the body of a request can be read only once. So it doesn’t matter how early you’re receiving it.
The
DoubleReceive
plugin solves the problem by reading a whole body and storing it for future reads.
d
How does ktor handle decompression of request body in the receive pipeline? Could it be possible to add a hook somewhere at that stage (the function would return the body unchanged, ie. identity transform)?
Btw, why is the read only once limitation imposed?
a
Because it may be inefficient to read a whole body in memory, especially, if it’s a huge one.