You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using with rails, I found it will have an error #<JWT::VerificationError: Signature verification raised> because jwt-multisig try to encode payload with not the same method when encoding signature.
Payload encoding relies on ActiveSupport::JSON.encode in rails ? which will escape HTML string in JSON body and it will not match to the signature which is not escaped. and also with DateTime as another issue #1
Add config.active_support.escape_html_entities_in_json = false in application.rb in rails. but it will affect the whole application (but still not fix for DateTime?).
Change payload encoding to be the same method as the signature. so it should be replaced base64_encode(payload.to_json) to be JWT::Base64.url_encode(JWT::JSON.generate(payload)) (same as signature encoding) or using JSON.dump can solve the issue also but it will not the same as signature encoded.
The text was updated successfully, but these errors were encountered:
jengjeng
changed the title
Mismatch payload with signature
Mismatch payload compared to signature
Dec 15, 2020
jengjeng
changed the title
Mismatch payload compared to signature
Mismatch payload compare to signature
Dec 15, 2020
jengjeng
changed the title
Mismatch payload compare to signature
Mismatch payload when compared to signature
Dec 15, 2020
We need to following the data processing flow here and find where we decode and re-encode between the signature and the verification.
The key is to make sure the json is NOT decoded and re-encoded.
PEATIO -> Signed message -> AMQP -> Mailer -> Verify the signature before decode
When using with rails, I found it will have an error
#<JWT::VerificationError: Signature verification raised>
becausejwt-multisig
try to encode payload with not the same method when encoding signature.Payload encoding relies on
ActiveSupport::JSON.encode
in rails ? which will escape HTML string in JSON body and it will not match to the signature which is not escaped. and also with DateTime as another issue #1example payload raised an error
I think we have 2 solutions for this case
config.active_support.escape_html_entities_in_json = false
inapplication.rb
in rails. but it will affect the whole application (but still not fix for DateTime?).base64_encode(payload.to_json)
to beJWT::Base64.url_encode(JWT::JSON.generate(payload))
(same as signature encoding) or usingJSON.dump
can solve the issue also but it will not the same as signature encoded.The text was updated successfully, but these errors were encountered: