Closed rvermeulen closed 7 years ago
hey looking at this. thanks.
I guess that comments should not be allowed during parsing of the json (eg "user//name" should be literally parsed as "user//name".) Disabling comments in jackson doesn't seem to fix the issue so I'll have to dig around. Thanks again - I'll have something out for this shortly.
Thanks for picking this up!
I quickly browsed the code and the issue is with
https://github.com/jasongoodwin/authentikat-jwt/blob/master/src/main/scala/authentikat/jwt/JwtClaimsSet.scala#L21 asJsonString
method that uses your SimpleJsonSerializer.scala
The SimpleJsonSerializer
doesn't escape the values.
Ah right - I forgot that was there. I removed it in the newer version. Flipping the serialization to jackson escapes the quotes but it won't parse the scenario correctly - the unapply returns None now. Getting closer though.
The claims set at this point looks like this: { "username": "x\",\"username\":\"kevinmitnick\",\"role\":\"admin\"}//", "role": "user" }
Edit: sorry it was escaping things in the display I just have to fix the parsing now as that should be parsed without any issues.
sorry - Fixed the presentation of that
Is it the comment at the end of the username that causes the parsing to go wrong?
Everything looks correctly escaped with exception of the comments part. I would expect something like \/\/
instead.
Could you check if unapply works without the comments part in the username?
The tokens produced look okay but the deserialization won't work with or without the "//" at the end of the string. I pushed a branch with the fix so far. I suspect that I need to change the jackson settings under json4s but doing so doesn't appear to impact the deserialization how I'm doing it. Check the branch if you want to have a look.
Released an initial fix as 0.4.4 It needs more work because // can break the deserialization. But I think it's important to release this.
Resolved. 0.4.5
escape json comments