Repository navigation
Let remote curators feature Groups in their collections (FEP-7aa9) #183
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| diff --git a/dist/middleware-BqefXH6B.js b/dist/middleware-BqefXH6B.js | ||
| index 51dee9c19027e60c6b0455def7b40da1af27179e..aa3223fa4d8bc4fc6611c61c3ed72900d9c99e13 100644 | ||
| --- a/dist/middleware-BqefXH6B.js | ||
| +++ b/dist/middleware-BqefXH6B.js | ||
| @@ -6003,6 +6003,40 @@ async function handleInboxInternal(request, parameters, span) { | ||
| status: "verified", | ||
| attempts: observation.verification.attempts.filter((attempt) => attempt.status === "verified") | ||
| }; | ||
| + // [moim patch] FEP-7aa9 interop: Mastodon's FeatureRequest carries no `actor` | ||
| + // (the FEP example omits it; Pixelfed accepts it the same way). Mastodon always | ||
| + // HTTP-signs deliveries, so authenticate the request by its HTTP Signature here | ||
| + // (Fedify skips that step once an LD Signature or proof has verified the body) | ||
| + // and use the key owner as the actor instead of rejecting with "Missing actor". | ||
| + if (activity.actorId == null && !skipSignatureVerification && getTypeId(activity).href === "https://w3id.org/fep/7aa9#FeatureRequest") { | ||
| + let signerKey = httpSigKey; | ||
| + if (signerKey == null) { | ||
| + const verification = await verifyRequestDetailed(request, { | ||
| + contextLoader: ctx.contextLoader, | ||
| + documentLoader: ctx.documentLoader, | ||
| + timeWindow: signatureTimeWindow, | ||
| + maxSignatures: maxHttpSignatures, | ||
| + keyCache, | ||
| + meterProvider, | ||
| + tracerProvider | ||
| + }); | ||
| + if (verification.verified) signerKey = verification.key; | ||
| + } | ||
| + const signer = signerKey == null ? null : await getKeyOwner(signerKey, { | ||
| + documentLoader: ctx.documentLoader, | ||
| + contextLoader: ctx.contextLoader, | ||
| + tracerProvider | ||
| + }); | ||
| + if (signer?.id != null) { | ||
| + logger.debug("FeatureRequest has no actor; using the HTTP signature key owner {actorId} as the actor (FEP-7aa9 interop).", { | ||
| + actorId: signer.id.href, | ||
| + recipient | ||
| + }); | ||
| + if (json != null && typeof json === "object" && !Array.isArray(json)) json.actor = signer.id.href; | ||
| + if (compactedJson != null && compactedJson !== json && typeof compactedJson === "object" && !Array.isArray(compactedJson)) compactedJson.actor = signer.id.href; | ||
| + activity = activity.clone({ actor: signer.id }); | ||
| + } else logger.warn("FeatureRequest has no actor and its HTTP Signature could not be resolved to an owner.", { recipient }); | ||
| + } | ||
| observation.stage = "dispatch"; | ||
| const routeResult = await routeActivity({ | ||
| context: ctx, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * FEP-7aa9 (Featured Collections) support — consumer side only. | ||
| * | ||
| * Moim lets remote curators (e.g. Mastodon "Collections") feature local | ||
| * Group actors. This is intentionally stateless: the approval stamp | ||
| * (`FeatureAuthorization`) encodes the collection URI in its own URL, so | ||
| * no table is needed. A stamp is valid as long as the Group still exists | ||
| * and its policy still allows the curator. | ||
| */ | ||
| import { InteractionPolicy, InteractionRule, PUBLIC_COLLECTION } from "@fedify/vocab"; | ||
| import type { Context } from "@fedify/fedify"; | ||
|
|
||
| /** Path segment: base64url of the collection URI (URL-safe, no padding). */ | ||
| export function encodeCollectionUri(collection: URL): string { | ||
| return Buffer.from(collection.href, "utf8").toString("base64url"); | ||
| } | ||
|
|
||
| export function decodeCollectionUri(segment: string): URL | null { | ||
| try { | ||
| const href = Buffer.from(segment, "base64url").toString("utf8"); | ||
| const url = new URL(href); | ||
| if (url.protocol !== "https:" && url.protocol !== "http:") return null; | ||
| return url; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Who may feature this Group. Mirrors Mastodon's own rule: | ||
| * locked (manually approves followers) → followers only; otherwise anyone. | ||
| */ | ||
| export function buildFeaturePolicy( | ||
| ctx: Context<void>, | ||
| identifier: string, | ||
| manuallyApprovesFollowers: boolean, | ||
| ): InteractionPolicy { | ||
| const allowed = manuallyApprovesFollowers | ||
| ? ctx.getFollowersUri(identifier) | ||
| : PUBLIC_COLLECTION; | ||
| return new InteractionPolicy({ | ||
| canFeature: new InteractionRule({ automaticApprovals: [allowed] }), | ||
| }); | ||
| } |
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
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.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
The stateless
FeatureAuthorizationdispatcher bypasses the locked-group policy.The dispatcher checks only that the local Group exists. It does not check
manuallyApprovesFollowers, and it does not check who owns the collection. Any party can build/ap/feature-authorizations/{group}/{base64url(any collection)}without sending aFeatureRequest. The server then returns a valid stamp, and itsinteractingObjectandinteractionTargetmatch.A remote curator who does not follow a locked Group can therefore publish a
FeaturedItemthat points to this URL. Remote verifiers will accept the item. The inbox Reject at Lines 904-919 does not prevent this. The file header also says a stamp is valid only while "its policy still allows the curator". The code does not enforce that condition.Choose one of these fixes for locked Groups:
attributedTo, and return the stamp only when that actor has anacceptedfollow to the Group. Returnnullin all other cases.For unlocked Groups, the current behavior matches the
PUBLIC_COLLECTIONpolicy.🤖 Prompt for AI Agents