-
-
Notifications
You must be signed in to change notification settings - Fork 98
Implement RFC 9421 §5 Accept-Signature challenge-response negotiation
#626
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
Merged
Merged
Changes from 36 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
1a2144d
Add utils to handle Accept-Signature
2chanhaeng 8ea783f
Add fulfillAcceptSignature
2chanhaeng 52b8a95
Add `rfc9421` param and fix related logic
2chanhaeng 2d5f4a0
Add `InboxChallengePolicy` interface and implement Accept-Signature h…
2chanhaeng 07a23f5
Add docs about RFC 9421 §5
2chanhaeng 2e415b4
Format
2chanhaeng c7d4fdd
Add tests for inbound
2chanhaeng cb8b43c
Add `doubleKnock()` loop prevention test
2chanhaeng 490ed50
Fix comments
2chanhaeng f37c162
Fix `http.ts`
2chanhaeng cc1c36c
Add changes
2chanhaeng 08823f3
Improve nonce verification logic and add test
2chanhaeng 828c093
Remove `requestCreated` attribute
2chanhaeng 3db2ddc
Retry challenge on `TypeError` in `doubleKnock`
2chanhaeng 1788323
Filter `@status` components
2chanhaeng 7810dd0
Fix nonce and challenge component issues in inbox handler
2chanhaeng 7d91283
Fix minor in docs
2chanhaeng edcf2ed
Fix null check
2chanhaeng f2432e2
Lint markdown
2chanhaeng 030f07b
Add PR
2chanhaeng 1257ee8
Initialize `pendingNonceLabel` as `undefined`
2chanhaeng ab7dcdd
Add conditional check for `kv.cas` in `verifySignatureNonce` function
2chanhaeng 8950cc0
Add `AcceptSignatureComponent` and fix related code
2chanhaeng 5d4d93d
Add `expires` attr
2chanhaeng 9243884
Remove not requested components
2chanhaeng d31f5d6
Refactor `derivedComponents`
2chanhaeng fe8a9e3
Fix `rfc9421` components
2chanhaeng 69e5048
Fix `rfc9421` components
2chanhaeng 15db464
Return non-negotiation failures from challenge retry directly
2chanhaeng 38097bf
Fulfill all compatible Accept-Signature entries
2chanhaeng 3dda5bf
Lint
2chanhaeng 71fdcae
Update components to `AcceptSignatureComponent[]` type
2chanhaeng 95b6ecc
Escape structured-field string
2chanhaeng d90f4a5
Add headers to `unverifiedActivityHandler` when 401
2chanhaeng 386e7b0
Add RFC 9421 interoperability field test example
2chanhaeng 87f5603
Add page view
2chanhaeng 5d77178
Lint
2chanhaeng 2fd8df1
Remove dangling
2chanhaeng 36d4ae1
Use `@hongminhee/localtunnel` in `startTunnel`
2chanhaeng 2ac48a1
Lint
2chanhaeng a91a3a6
Show signature spec
2chanhaeng 24eddc0
Lint
2chanhaeng 836d40a
Skip `rfc-9421-test` while testing examples
2chanhaeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| RFC 9421 Interoperability Field Test | ||
| ===================================== | ||
|
|
||
| A Fedify-based server for testing RFC 9421 HTTP Message Signatures | ||
| interoperability with Bonfire, Mastodon, and other fediverse implementations. | ||
|
|
||
| See [../../plans/field-test.md](../../plans/field-test.md) for the full test | ||
| plan. | ||
|
|
||
|
|
||
| Prerequisites | ||
| ------------- | ||
|
|
||
| - [Deno] installed | ||
| - Run `mise run install` (or `pnpm install`) from the repo root | ||
| - A public tunnel for testing (e.g., `fedify tunnel`) | ||
|
|
||
|
|
||
| Quick start | ||
| ----------- | ||
|
|
||
| ### 1. Start the server | ||
|
|
||
| ~~~~sh | ||
| # Default (RFC 9421 first knock + Accept-Signature challenge): | ||
| deno run -A main.ts | ||
|
|
||
| # With nonce replay protection: | ||
| CHALLENGE_NONCE=1 deno run -A main.ts | ||
|
|
||
| # Without challenge (plain signature verification only): | ||
| CHALLENGE_ENABLED=0 deno run -A main.ts | ||
| ~~~~ | ||
|
|
||
| ### 2. Expose publicly with `fedify tunnel` | ||
|
|
||
| In a separate terminal, from the repo root: | ||
|
|
||
| ~~~~sh | ||
| deno task cli tunnel 8000 | ||
| ~~~~ | ||
|
|
||
| Note the public URL (e.g., `https://xxxxx.tunnel.example`). | ||
|
|
||
| ### 3. Send test activities | ||
|
|
||
| Open your browser or use curl. Both GET (query params) and POST (JSON body) | ||
| are supported: | ||
|
|
||
| ~~~~sh | ||
| # Follow a remote actor (GET): | ||
| curl 'https://xxxxx.tunnel.example/send/follow?handle=@user@bonfire.example' | ||
|
|
||
| # Follow a remote actor (POST): | ||
| curl -X POST -H 'Content-Type: application/json' \ | ||
| -d '{"handle":"@user@bonfire.example"}' \ | ||
| https://xxxxx.tunnel.example/send/follow | ||
|
|
||
| # Send a note: | ||
| curl 'https://xxxxx.tunnel.example/send/note?handle=@user@bonfire.example&content=Hello!' | ||
|
|
||
| # Unfollow: | ||
| curl 'https://xxxxx.tunnel.example/send/unfollow?handle=@user@bonfire.example' | ||
| ~~~~ | ||
|
|
||
|
|
||
| Configuration | ||
| ------------- | ||
|
|
||
| All configuration is via environment variables: | ||
|
|
||
| | Variable | Default | Description | | ||
| |---------------------|-------------|-------------------------------------------| | ||
| | `PORT` | `8000` | Server listen port | | ||
| | `FIRST_KNOCK` | `rfc9421` | Initial signature spec (`rfc9421` or `draft-cavage-http-signatures-12`) | | ||
| | `CHALLENGE_ENABLED` | (enabled) | Set to `0` to disable `Accept-Signature` on `401` | | ||
| | `CHALLENGE_NONCE` | (disabled) | Set to `1` to include one-time nonce | | ||
| | `NONCE_TTL` | `300` | Nonce time-to-live in seconds | | ||
|
|
||
|
|
||
| Endpoints | ||
| --------- | ||
|
|
||
| ### Monitoring | ||
|
|
||
| - `GET /` — Server info and endpoint list | ||
| - `GET /log` — Received activities (newest first) | ||
| - `GET /followers-list` — Current followers | ||
|
|
||
| ### Sending activities (outbound) | ||
|
|
||
| All send endpoints accept GET (query params) or POST (JSON body). | ||
|
|
||
| - `/send/follow` — Send a Follow activity | ||
| - `handle` (required): remote actor handle | ||
| - `/send/note` — Send a Create(Note) activity | ||
| - `handle` (required): remote actor handle | ||
| - `content` (optional): note text | ||
| - `/send/unfollow` — Send an Undo(Follow) activity | ||
| - `handle` (required): remote actor handle | ||
|
|
||
|
|
||
| Test scenarios | ||
| -------------- | ||
|
|
||
| ### Scenario A: Fedify -> Bonfire (outbound) | ||
|
|
||
| 1. Start the server and expose via tunnel. | ||
| 2. Use `/send/follow` and `/send/note` to send activities to a Bonfire actor. | ||
| 3. Check Bonfire server logs for RFC 9421 signature verification. | ||
|
|
||
| ### Scenario B: Bonfire -> Fedify (inbound with challenge) | ||
|
|
||
| 1. Start the server with `CHALLENGE_ENABLED=1`. | ||
| 2. Have Bonfire send a `Follow` to `@test@<your-domain>`. | ||
| 3. Verify Fedify returns `401` with `Accept-Signature` header. | ||
| 4. Verify Bonfire retries with a compatible signature and succeeds. | ||
| 5. Repeat with `CHALLENGE_NONCE=1` for replay protection testing. | ||
|
|
||
| ### Scenario C: Fedify -> Mastodon (outbound) | ||
|
|
||
| 1. Start the server and expose via tunnel. | ||
| 2. Use `/send/follow` targeting a Mastodon actor. | ||
| 3. Monitor logs for double-knock behavior and 5xx workaround. | ||
|
|
||
| ### Scenario D: Mastodon -> Fedify (inbound) | ||
|
|
||
| 1. Start the server (optionally with challenge enabled). | ||
| 2. From a Mastodon account, follow `@test@<your-domain>`. | ||
| 3. Check the `/log` endpoint and server logs. | ||
|
|
||
| [Deno]: https://deno.com/ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think it's a dangling pointer?