Swift-JWT icon indicating copy to clipboard operation
Swift-JWT copied to clipboard

Decode issue

Open phanindhraB opened this issue 3 years ago • 5 comments

I'm Sending the finalized JWT String in Header and expected to get a response as same but it is changing the decode response Screenshot 2022-01-20 at 11 22 40 AM

This is the cryptogram after encoding eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJhbW91bnQiOiIxLjAwIiwiZGV2aWNlSWQiOiJGRjY0QUUwOS02NkVDLTQ3QTMtODkwQy01MkE0RjE1MzFEOTEiLCJjcmVkaXRvckFjY291bnQiOiIyNTUyNTI1MjIiLCJlbmRUb0VuZElkIjoiQ01DTE1VTTAyMDIyMDEyMDAwMDAwMSIsImRlYnRvckFjY291bnQiOiIxMjM0NTY3OCIsImN1cnJlbmN5IjoiTVVSIiwiY29uc2VudElkIjoiODgzNzkifQ.GiIAaPBxa-Rsf6AjYWDVPpfvlqpau_qkADGHixskS2knONHDQv8wK1MleCcr4MViRcSCoSFl195BhqI9Pp4yE31OFd_O59O7FSDY1jt7ZIfkdZa9YHxz9QMgq-rk3f7S4m_REThgrTEVo9DsbTWNuuhE2XuJtKbovFxTFF_4_zftXWfoQ9bufW9BbLeUWwzLrUPrTKrPpon6DEy5nV0Sy-dufCJKt9X3-79La-2xgqPSjtybrQMlGg78gaVQF7tjya6dTrPMQ8j-TIyeaRdRQIsJm8xOl99wOEP7wA6JwxSqQsjeUTXRHPIikixcPTs8oybEbCh5qCZULz-LnOXYJw

if i see this decoding cryptogram in JWT, it is changing the json response

Screenshot 2022-01-20 at 11 26 00 AM

phanindhraB avatar Jan 20 '22 05:01 phanindhraB

@dannys42 @bluk @e0 @mbarnach any response on the decoded object ??

phanindhraB avatar Mar 16 '22 10:03 phanindhraB

@phanindhraB What is different? I cannot spot the difference here. Do you mean your JWT is altered in anyways? But between what and what?

mbarnach avatar Mar 16 '22 15:03 mbarnach

@mbarnach I mean, passing Claim struct object with an order for creating encoding object, if I decode the object using JWT, the order of the Claim struct object is changing. you can see the above comment.

phanindhraB avatar Mar 17 '22 05:03 phanindhraB

@phanindhraB JSON are coded as dictionary, so order is not preserved. If you are using a decodable struct, it shouldn't matter. Otherwise, you will have to provide your own encoder/decoder with ordered dictionary.

mbarnach avatar Mar 17 '22 07:03 mbarnach

I am running into a similar issue. I've created my own encoding/decoding function in the Claims struct I made. I am getting a value not found.

josephjoeljo avatar May 13 '23 19:05 josephjoeljo