-
Notifications
You must be signed in to change notification settings - Fork 81
Signature: Move HTTP request signing to a filter #1994
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
Conversation
Moved HTTP request signing to a filter in Signature::init and removed direct calls from Http class. Updated Signature class to add filters for signing and double knock logic. Adjusted tests to use filter-based approach for signature verification.
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
This PR refactors HTTP request signing logic from direct method calls to a filter-based approach, improving code organization and consistency. The changes move signature handling into filters that are automatically applied to all HTTP requests.
- Moves HTTP request signing from direct calls in Http class to a filter in Signature::init()
- Implements automatic double-knock fallback logic through HTTP response filtering
- Updates test infrastructure to work with the new filter-based approach
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
activitypub.php | Adds Signature::init() to the initialization sequence |
includes/class-signature.php | Implements init() method with filters for request signing and double-knock logic |
includes/class-http.php | Removes direct Signature::sign_request() calls and redundant method specifications |
tests/includes/class-test-signature.php | Updates test to use specific filter removal instead of remove_all_filters |
Comments suppressed due to low confidence (1)
includes/class-signature.php:38
- The removed wp_parse_args() call that sets default method and Date header is essential for signature generation. Without these defaults, the signing process may fail when these values are not provided by the caller.
public static function sign_request( $args, $url ) {
You remove the I wonder why the tests are green 🤔 |
Ah, the test is still adding the |
Yes, that would be expected. Tests create signatures manually to sign "incoming" requests and they need the method provided. When signing outgoing requests, |
nice job! |
Updated signature-related tests to apply the 'http_request_args' filter directly instead of invoking the sign() method. Also added setup and cleanup for the 'activitypub_rfc9421_signature' option in the RFC9421 test to ensure proper test isolation.
Follow up to #1986 and #1991.
Moves double-knock into a filter that's always set.
With
Signature
getting an init callback, we can now also move the signing logic into a hook callback.Proposed changes:
Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Moved HTTP request signing to a filter instead of calling it directly.