Skip to content

Conversation

@sij411
Copy link
Contributor

@sij411 sij411 commented Jan 17, 2026

Summary

  • Add -A/--authorized-fetch option to fedify inbox command
  • When enabled, incoming requests without valid HTTP Signatures are rejected with 401 Unauthorized
  • Useful for testing whether ActivityPub servers correctly sign outgoing requests

Changes

  • Added -A/--authorized-fetch CLI option to inbox command
  • Implemented HTTP signature verification using verifyRequest() in the fetch handler
  • Added documentation in docs/cli.md

Closes #229

🤖 Generated with Claude Code

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sij411, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the fedify inbox command-line tool by adding an optional authorized fetch mode. When enabled, the inbox server will enforce HTTP signature verification on all incoming requests, rejecting those that are unsigned or have invalid signatures. This provides a valuable testing utility for developers working with ActivityPub implementations, allowing them to confirm that their servers are correctly signing outgoing requests as required by many fediverse platforms.

Highlights

  • New CLI Option: Introduced the -A/--authorized-fetch option to the fedify inbox command, enabling a mode where incoming requests require valid HTTP signatures.
  • HTTP Signature Verification: Implemented HTTP signature verification for requests received by the fedify inbox server when the authorized fetch mode is active. Requests without valid signatures are rejected with a 401 Unauthorized status.
  • Testing Utility: This feature is designed to assist in testing ActivityPub servers to ensure they correctly sign their outgoing requests, which is crucial for interoperability with secure fediverse instances.
  • Documentation Update: Added comprehensive documentation for the new -A/--authorized-fetch option in docs/cli.md, explaining its functionality and use cases.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@issues-auto-labeler issues-auto-labeler bot added component/cli CLI tools related component/federation Federation object related component/inbox Inbox related component/signatures OIP or HTTP/LD Signatures related labels Jan 17, 2026
@sij411
Copy link
Contributor Author

sij411 commented Jan 17, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new --authorized-fetch (-A) option to the fedify inbox command. This feature is useful for testing ActivityPub server implementations by enforcing that all incoming requests are signed with valid HTTP Signatures, rejecting unsigned or invalid ones with a 401 Unauthorized status. The implementation is straightforward, adding the CLI option and integrating verifyRequest into the fetch handler. The documentation has also been updated accordingly.

My review found a minor issue with the clarity of the CLI option's description, and I've provided a suggestion to improve it. Overall, this is a valuable addition for developers working with Fedify.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a useful --authorized-fetch option to the fedify inbox command for testing signed requests. The implementation is mostly correct, but there are a couple of areas for improvement.

First, the description for the new CLI option is slightly ambiguous and could be rephrased for better clarity.

More importantly, there's a performance issue where HTTP signatures are verified twice for each request when the new option is enabled. This happens once in the new logic and again within the federation.fetch() call. I've suggested a couple of ways to address this to avoid the redundant work.

Overall, a great addition for improving the testing capabilities of the CLI.

@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sij411 sij411 marked this pull request as ready for review January 19, 2026 17:05
Replace manual verifyRequest() in fetch handler with Fedify's
authorization predicates on actor and collection dispatchers.

This is the idiomatic Fedify approach and covers:

- Actor fetches
- Inbox POST (built-in)
- Followers, following, outbox collections

WebFinger and NodeInfo remain public, matching real-world
authorized fetch implementations like Mastodon's secure mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sij411
Copy link
Contributor Author

sij411 commented Jan 19, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new --authorized-fetch option to the fedify inbox command, which is a great feature for testing server-to-server authentication. The implementation is well-done, moving the federation setup into the runInbox function to accommodate the new conditional logic. The documentation is also clear and helpful. I have one suggestion to improve code maintainability by reducing duplication in the authorization logic.

@sij411
Copy link
Contributor Author

sij411 commented Jan 20, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new --authorized-fetch option to the fedify inbox command, which is a great addition for testing signed requests. The implementation correctly uses an authorize predicate to protect GET endpoints. The associated documentation is also clear and helpful. I've identified a couple of areas for improvement. First, the behavior for unsigned POST requests to the inbox when the flag is disabled doesn't seem to match the feature's intent, which can be fixed by configuring skipSignatureVerification. Second, there's an opportunity to improve robustness by managing the module-level state more carefully. Overall, this is a valuable feature with a solid implementation foundation.

…ication

- Reset module-level state at the beginning of runInbox to avoid state
  leaking between calls (e.g., during testing)
- Set skipSignatureVerification: !authorizedFetchEnabled to make inbox
  permissive when -A flag is off, and strict when enabled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sij411
Copy link
Contributor Author

sij411 commented Jan 20, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable --authorized-fetch option to the fedify inbox command, enabling testing of HTTP signature verification. The implementation is solid, correctly using skipSignatureVerification for inbox deliveries and an authorize predicate for resource fetching. A significant and commendable part of this PR is the refactoring of the runInbox function, which moves module-level logic into the function scope. This greatly improves the command's encapsulation, state management, and testability. I have one suggestion to optimize a repeated function call.

sij411 and others added 6 commits January 20, 2026 18:49
Replace manual verifyRequest() in fetch handler with Fedify's
authorization predicates on actor and collection dispatchers.

This is the idiomatic Fedify approach and covers:

- Actor fetches
- Inbox POST (built-in)
- Followers, following, outbox collections

WebFinger and NodeInfo remain public, matching real-world
authorized fetch implementations like Mastodon's secure mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ication

- Reset module-level state at the beginning of runInbox to avoid state
  leaking between calls (e.g., during testing)
- Set skipSignatureVerification: !authorizedFetchEnabled to make inbox
  permissive when -A flag is off, and strict when enabled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
sij411 and others added 3 commits January 20, 2026 21:23
The actor endpoint must be publicly accessible so that other servers
can fetch the public key to verify HTTP signatures. Requiring
authorization on the actor endpoint breaks the trust chain for
authorized fetch.

Dispatchers with authorization (require HTTP signature when -A enabled):

- setFollowersDispatcher: protects follower collection
- setFollowingDispatcher: protects following collection
- setOutboxDispatcher: protects outbox collection

Dispatchers without authorization (publicly accessible):

- setActorDispatcher: must be public for key fetching per instance
  actor specification

References:

- https://swicg.github.io/activitypub-http-signature/#instance-actor
- https://seb.jambor.dev/posts/understanding-activitypub-part-4-threads/#the-instance-actor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Store the result of ctx.getActorKeyPairs(identifier) in a variable
to avoid calling it twice, improving performance and readability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Instead of removing .authorize() from the actor dispatcher entirely,
use a dedicated instanceActor predicate that:

- Returns true for identifier "i" (instance actor is always public)
- Delegates to authorize() for other identifiers

This approach keeps .authorize() on the actor dispatcher while ensuring
the instance actor remains publicly accessible for key fetching per the
ActivityPub HTTP Signature spec.

Reference: https://swicg.github.io/activitypub-http-signature/#instance-actor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add a separate instance actor that is always publicly accessible for
key fetching, while the normal actor requires authorized fetch when
-A is enabled:

- i: normal actor, requires authorized fetch with -A
- ia: instance actor, always public for key fetching

Both actors share the same key pairs since they're ephemeral and
controlled by the same CLI instance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; thanks!

@dahlia dahlia merged commit fa81592 into fedify-dev:main Jan 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli CLI tools related component/federation Federation object related component/inbox Inbox related component/signatures OIP or HTTP/LD Signatures related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add -A/--authorized-fetch option to fedify inbox command

2 participants