krakend / krakend-jose

Javascript Object Signing and Encryption (JOSE) component for the KrakenD framework
http://www.krakend.io
Apache License 2.0
33 stars 49 forks source link

"propagate_claims" with empty array value got 500 and empty resp body #121

Open AlAnwari-ari opened 1 year ago

AlAnwari-ari commented 1 year ago

I'm using "propagate_claims" and want to put the header value with its token data. But suddenly i got 500 response code and no body response when i got empty array. ex: "auth/validator": { ... "propagate_claims": [["group", "X-GROUP"]] } and group value is empty array group:[] anything insight would be very appreciate it... thank you

alombarte commented 10 months ago

Thank you @AlAnwari-ari, we will look into this shortly and get back to you

dhontecillas commented 10 months ago

@AlAnwari-ari : I've create a branch to try to reproduce the issue here : https://github.com/krakend/krakend-jose/pull/125/files

Just so I understand it correctly: you issue is that some claim in jwt has a value of an array, when that array has some value, your request succeeds, but when it is empty, you get an error ?

I would need more information about how to reproduce it, mostly because, looking at the code here: https://github.com/krakend/krakend-jose/blob/master/jose.go#L265 does not look like it could fail , in case of an empty array, it would return an empty string value.

However, if the issue is that "group" is not an empty array, but is just a key that is not there, the behaviour was for the header to not be there .

On the other side, if the "group" key is there, but with a null value, the Header will be set with an string value of "null" (the behaviour can be found in this example https://go.dev/play/p/JbVTfL3E3fu?v=goprev ) .

But, in any case, it should not break , or produce an error.

Take into account, that in the soon to be released new CE version, the behaviour will be different, and the header will be always there, set to empty string if no value is there.

In any case, I could not reproduce the error issue.. so I wonder if the error is the side effect of not having the expected headers somewhere down in the pipeline, or produced by the response of a backend that was expecting the header to be there.