Hi all!
I've just started with Kotlin and Ktor and I'm setting up a server with JWT authentication.
I want the server to respond with a 401 code and a relevant message when the token is incorrect. For example, if the claim
userId
is missing then I would like to have a response saying "Claim 'userId' is missing". I don't think it's currently possible in Ktor and I would like to add it to Ktor.
Can any of you offer some insight in whether (a) this is a good feature and (b) how I would go about adding this?
The Java library that parses the JWT returns useful information in an exception, but this information is then discarded and an empty UnauthorizedResponse is sent. I think the solution is to add this information to the UnauthorizedResponse as a response body.
Jeremy Guijt
03/25/2020, 4:14 PM
Does anyone think that this is a good/bad idea? Or should I make an issue on Github?
s
Shawn
03/25/2020, 4:19 PM
it’s not like, intrinsically useful imo, for most inter-service communication I’d rather just have the called service log the error and then return the 401 normally