Open Spikhalskiy opened 1 year ago
I was able to solve it by registering
@Singleton
class TokenAuthenticationArgumentBinder : AbstractPrincipalArgumentBinder< TokenAuthentication >(
TokenAuthentication::class.java,
)
but it feels like it shouldn't have to be done explicitly.
If such a binder is really expected to be present by design, it would be great if the error message could be improved to point out on the fact that there is no applicable RequestArgumentBinder found for the class.
Yes, I think the creation of the RequestArgumentBinder
is required. we should improve the docs.
Also, it would be great if an error message could be replaced with something meaningful. If you know netty, it's clear what happens here - we try to use the body a second time. But for a lot of users, it may be a very obscure exception.
Expected Behavior
The following works correctly and
method
gets access to an instance of our own classTokenAuthentication
But it requires an ugly cast in every method. We expect that
will also work and save us from
Authentication
->TokenAuthentication
cast.Actual Behaviour
It looks like that if a custom subclass of
io.micronaut.security.authentication.Authentication
is used, Micronaut doesn't pick it up as aAuthentication
and tries to deserialize body of the request into this object the second time.Version
platform: 4.0.5