Files
Sylvain Duchesne 88f23b7023 Harden the backend's trust surface: an allow-listed public surface, decisions taken on data re-read from the pod
The backend served its settings dataset (including the app actor's private key) to anonymous callers, through the SPARQL endpoint and through the semapps LDP catch-all route, since WebACL is off. An allow-list mounted on every route now exposes only what the app and the pod need (/app, /as/actor/app and its Client ID Document, /catalog, the public key, access needs, the JSON-LD context, nodeinfo, the app inbox and the webhook endpoint); everything else answers 404.

Every watcher-fed service (public read, catalog, attendees, contacts, registration) now decides on the activity and object re-read from the pod as the app, checks they belong to the outbox owner and that the stored object has the expected type, and never acts on the notification body. Decisions for one object are serialized and taken on a read made when acting, with a 30 s bound and an abort check before every write. The anonymous read follows the event's visibility both ways, attendees collection included; Festipod records the grants it makes and revokes only those, leaving any other public share untouched; an unreadable ACL changes nothing. A participant's attendance follows their latest act by the pod's timestamp, not the order notifications arrive. Known limits (no conditional write on the pod, a write in flight at the timeout) are documented in the code.
2026-10-13 16:30:52 +02:00

46 lines
2.0 KiB
JavaScript

const urlJoin = require('url-join');
const { PodCollectionsHandlerMixin, PodResourcesHandlerMixin } = require('@activitypods/app');
const CONFIG = require('../config/config');
const { neverThrowingMatcher, verifiedEmit } = require('./emitted-activity');
const { guardedCreateAndAttach } = require('./collection-attach');
// Attaches an `apods:contacts` collection (and a WAC group of the same members) to the `as:Profile`
// a user creates, as the platform's collection handler does — with two differences that keep the
// webhook a hint (see emitted-activity.js):
// - the handler runs only for a Create `verifiedEmit` accepts: re-read from the pod as the app,
// attributed to the owner of the outbox the webhook fired on, its object an `as:Profile` of that
// owner's pod, re-read too. The mixin's handler would act on the object embedded in the
// (unauthenticated) webhook body, attributed to the activity's self-declared `actor`;
// - `createAndAttach` creates no WAC group when nothing was attached (collection-attach.js).
module.exports = {
name: 'contacts',
mixins: [PodCollectionsHandlerMixin],
settings: {
shapeTreeUri: urlJoin(CONFIG.SHAPE_REPOSITORY_URL, 'shapetrees/as/Profile'),
attachPredicate: 'http://activitypods.org/ns/core#contacts',
collectionOptions: {
ordered: false,
summary: 'Festipod contacts'
},
createWacGroup: true
},
// Replaces the mixin's whole map (moleculer does not merge a custom schema key). The mixin's
// update and delete handlers are left out on purpose: they never matched here (they require an
// `onUpdate` this service does not have).
activities: {
create: {
match: neverThrowingMatcher(PodResourcesHandlerMixin.activities.create.match),
onEmit: verifiedEmit(
'Create',
async function (ctx, { object }, actorUri) {
await this.onCreate(ctx, object, actorUri);
},
{ objectType: 'Profile' }
)
}
},
actions: {
createAndAttach: guardedCreateAndAttach
}
};