-
Notifications
You must be signed in to change notification settings - Fork 245
Implement RFC-7797 / JWS (Detached Payload) #166 #272
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
base: master
Are you sure you want to change the base?
Conversation
is this validated? working as expected? But the java jose4j are this is not giving me same result. @chayan-datta @finvu Can you please help? |
One minor suggestion @prajurock, after converting it to JSON string, please remove the spaces. It will give you the result you want. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
The PR implements support for RFC-7797 detached JWS payloads and updates the typ header per RFC7515.
- Added sign_detached function to sign JWS with detached payloads
- Updated verify and _load functions to handle detached payloads and incorporated new tests that validate both detached and encoded detached use cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/test_jws.py | Updated header "typ" to "JOSE" and added tests for detached JWS payloads |
jose/jws.py | Introduced sign_detached, modified verify and _load to support detached mode, updated _encode_header header |
|
||
Returns: | ||
str: The string representation of the header, and signature in detached jws format | ||
payload: the payload as received in the request or encoed if {"b4":True} header is passed in the call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are typographical errors in the sign_detached() docstring; 'encoed' should be 'encoded' and 'b4' should be 'b64'.
Copilot uses AI. Check for mistakes.
else: | ||
if "b64" in header and header["b64"] is True: | ||
payload = _encode_payload(payload) | ||
signing_input = b"".join([signing_input, payload]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a payload is provided for a detached JWS, concatenating signing_input and payload without a delimiter may produce an incorrect signing input. Consider reviewing whether a '.' separator is required to correctly reassemble the original signing input.
signing_input = b"".join([signing_input, payload]) | |
signing_input = b".".join([signing_input, payload]) |
Copilot uses AI. Check for mistakes.
This is a contribution for issue number #166. I have also observed that as per rfc7515, section 4.1.9 the recommended value for typ header should be "JOSE" and hence include that change as well. Two tests have been added test_RSA256_detached() and test_RSA256_detached_encoded()