Closed joshuagrisham-karolinska closed 6 months ago
Hi @joshuagrisham-karolinska.
Your observation is correct. The fact that the provided API is expecting valid JSON makes it necessary to escape strings in the way you show it above. The JSON standard describes valid tokens and in case such tokens are used "standalone" a string token has to be explicitly quoted. Handling this in a different way would break the JSON standard semantics and potentially also existing tooling that is used against the API could break if this gets changed. I hope this explains why I'm rather hesitant to do that.
Irrespective of this, I'd be interested to learn what you are doing with the API and how you are using it? In my experience and based on the usage of others, it's very rarely if at all necessary to actually encrypt / decrypt single JSON tokens. Do you really have that requirement? Also, could you maybe instead make use of other API endpoints (e.g. a map with just one entry, or using the value with config endpoint) to achieve your goals?
Closing this for now due to lack of activity. Feel free to re-open if more discussion is appreciated.
In the end this is a bit of a "nice to have" but it would be quite helpful and less confusing for us if there was a way to use the
funqy-http-kryptonite
with single value strings without having to wrap the value in quotes, and to receive the value back without it being wrapped in quotes.E.g. if I run an instance of the server and try to encrypt a value like this:
Then the response is an empty HTTP 400 error and there is an exception logged in the container:
But if we instead wrap the value in quotes then it works (though the value we receive back is also wrapped in quotes):
I can understand that it seems to be expecting "valid json" as the input and returning "valid json" as the output, but honestly if we had a way avoid wrapping the values in quotes and then that the value we receive back were also not wrapped in quotes, then it would remove pre processing and post processing that we need to do every time we are using this service currently 😎
Maybe it could be a separate endpoint to specify we are sending a string e.g.
/encrypt/string
or/encrypt/value/string
which could handle the pre- and postprocessing logic for us? Or any other idea would be welcome, of course!