-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for detached payload in jws.Sign() #541
Comments
@stevenvegt This seems like a bug. I have a feeling I messed up on one of the tests, and its effect kind of just rippled elsewhere. Can you please try out https://github.com/lestrrat-go/jwx/tree/gh-541? FYI: It's my bed time where I live, so my next response will take a while |
@stevenvegt Please let me know if this worked? Thanks |
Thanks for the quick response! The suggested code works! However, I don't think your original code was wrong. It covered the Section 5.2:
So I think the solution might be providing an extra option to the sign function to indicate if the payload is detached or not. |
My assumption is that the payload HAS to be detached in presence of |
hmm maybe you are right. I will revisit later |
Yeah, okay, I get it https://datatracker.ietf.org/doc/html/rfc7797#section-5.2 |
Alright, so now it's coming down to the problem API design. It turns out that I've already used Now, the problem is with the method signature for jws.Sign(payload, alg, key, options...) We can't use jws.Sign(nil, alg, key, jws.WithDetachedPayload(payload)) .... and at this point I'm not sure if this is kosher. Maybe it's okay if we document it in really large bold print pointing out this is weird, but you must follow it until we fix it in the next major version? WDYT? |
@stevenvegt Okay, can you take a look at https://github.com/lestrrat-go/jwx/tree/gh-541 at commit 3fe6322? |
Yes. This will work and keeps everything backwards compatible 👍 |
Thanks for checking. Filed #543, and I'm going to sit on it at least overnight. |
Hello! I'm not sure if this is a bug, or just lack of support for detached payloads in a JWS.
Describe the bug
When making a detached signature, the payload does not have to be encoded. As is specified here:
RFC7797 Section 5.1:
However, the Signing method checks for a dot (
.
) in the payload which makes it impossible to create a detached signature with a raw byte payload from a hash function.jwx/jws/message.go
Lines 138 to 145 in 3774a6e
Go Version:
go version go1.17.2 darwin/arm64
To Reproduce / Expected behavior
This gives the
errors.New(`payload must not contain a "." when b64 = false`)
A possible change to make Sign compatible with detached signatures is a option like:
The text was updated successfully, but these errors were encountered: