Good morning.
I'm having problems to get my custom plugin interact with the Authentication plugin:
I need the response status code within a
on(ResponseBodyReadyForSend)
hook.
I can get it from
call.response.status()
in most cases - but not, when authentication has failed.
In that case, I get a
null
result. The actual
401
status code seems to be generated somewhere later in the plugin chain.
My custom plugin is installed after the Authentication plugin.
How can I retrieve the real status code which is sent to the client within my custom plugin?
my custom plugin needs to modify the response:
It's purpose is to add a header containing a cryptographic signature over some properties of the response (including the response status).
Where is the status code actually determined in case of a failed authentication?
a
Aleksei Tirman [JB]
12/07/2023, 8:45 AM
It's determined in the
AuthenticationHook
hook
Aleksei Tirman [JB]
12/07/2023, 8:48 AM
Then you can use the following code to determine the status:
Copy code
on(ResponseBodyReadyForSend) { call, content ->
if (content is UnauthorizedResponse) {
println(content.status)
}
}