Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix(api): use the public address for the ActivityPub actor (#3778)

Hampus5a0b05f7bee2
diff --git a/fluxer_api/src/api/activity_pub/ActivityPubController.ts b/fluxer_api/src/api/activity_pub/ActivityPubController.ts
index 8808851d8..2f67dcf66 100644
--- a/fluxer_api/src/api/activity_pub/ActivityPubController.ts
+++ b/fluxer_api/src/api/activity_pub/ActivityPubController.ts
@@ -22,7 +22,7 @@ export function ActivityPubController(app: HonoApp) {
if (publicKeyPem === null) {
return AppNotFoundHandler(ctx);
}
- return ctx.body(JSON.stringify(buildActivityPubActor(Config.endpoints.apiPublic, publicKeyPem)), 200, {
+ return ctx.body(JSON.stringify(buildActivityPubActor(Config.endpoints.apiPublicDiscovery, publicKeyPem)), 200, {
'Content-Type': ACTIVITY_PUB_CONTENT_TYPE,
'Cache-Control': DOCUMENT_CACHE_CONTROL,
});
@@ -31,7 +31,7 @@ export function ActivityPubController(app: HonoApp) {
if ((await getUnfurlerService().activityPubPublicKey()) === null) {
return AppNotFoundHandler(ctx);
}
- return ctx.body(JSON.stringify(buildActivityPubOutbox(Config.endpoints.apiPublic)), 200, {
+ return ctx.body(JSON.stringify(buildActivityPubOutbox(Config.endpoints.apiPublicDiscovery)), 200, {
'Content-Type': ACTIVITY_PUB_CONTENT_TYPE,
});
});
@@ -45,7 +45,7 @@ export function ActivityPubController(app: HonoApp) {
if ((await getUnfurlerService().activityPubPublicKey()) === null) {
return AppNotFoundHandler(ctx);
}
- const document = buildWebFinger(Config.endpoints.apiPublic, ctx.req.query('resource'));
+ const document = buildWebFinger(Config.endpoints.apiPublicDiscovery, ctx.req.query('resource'));
if (document === null) {
return AppNotFoundHandler(ctx);
}
diff --git a/fluxer_api/src/api/app/MiddlewarePipeline.ts b/fluxer_api/src/api/app/MiddlewarePipeline.ts
index aab557634..176e7203d 100644
--- a/fluxer_api/src/api/app/MiddlewarePipeline.ts
+++ b/fluxer_api/src/api/app/MiddlewarePipeline.ts
@@ -48,6 +48,7 @@ export function configureMiddleware(routes: HonoApp, options: MiddlewarePipeline
routes.use(PeerAddressMiddleware);
routes.use('/webhooks/:webhook_id/:token', cors({origins: '*'}));
routes.use('/webhooks/:webhook_id/:token/messages/:message_id', cors({origins: '*'}));
+ routes.use('/.well-known/webfinger', cors({origins: '*'}));
routes.use(
'/.well-known/fluxer',
cors({
diff --git a/fluxer_api/src/api/middleware/ServiceSingletons.ts b/fluxer_api/src/api/middleware/ServiceSingletons.ts
index d5ac1a0c5..2f987eddb 100644
--- a/fluxer_api/src/api/middleware/ServiceSingletons.ts
+++ b/fluxer_api/src/api/middleware/ServiceSingletons.ts
@@ -360,7 +360,7 @@ const getDefaultUnfurlerService = singleton(() => {
manager,
async () => instanceConfigRepository.getEffectiveYoutubeApiKey(),
async () => (await instanceConfigRepository.getEffectiveGifConfig()).klipy_api_key,
- activityPubKeyId(Config.endpoints.apiPublic),
+ activityPubKeyId(Config.endpoints.apiPublicDiscovery),
);
});
diff --git a/fluxer_docs/src/content/docs/operator/environment.mdx b/fluxer_docs/src/content/docs/operator/environment.mdx
index 57a8e276e..7aa64bcbe 100644
--- a/fluxer_docs/src/content/docs/operator/environment.mdx
+++ b/fluxer_docs/src/content/docs/operator/environment.mdx
@@ -150,7 +150,7 @@ The API base URL Fluxer hands to clients. When it's empty, Fluxer uses the publi
### `FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT`
-The public API base URL Fluxer lists in instance discovery as `api_public`. When it's empty, Fluxer uses `FLUXER_API_ENDPOINT`. Webhooks, signed links and federation always use `FLUXER_API_ENDPOINT`. With rexctl, use `rexctl config set FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT`.
+The public API base URL Fluxer lists in instance discovery as `api_public`. The ActivityPub actor and its key ID use the same address, so its host must serve `/.well-known/webfinger`, and changing it on an instance with a signing key gives remote servers a new actor. When it's empty, Fluxer uses `FLUXER_API_ENDPOINT`. Webhooks, signed links and Bluesky sign-in always use `FLUXER_API_ENDPOINT`. With rexctl, use `rexctl config set FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT`.
### `FLUXER_APP_ENDPOINT`
diff --git a/fluxer_rexctl/internal/instance/envvars.go b/fluxer_rexctl/internal/instance/envvars.go
index f3d48b2fe..4812b5921 100644
--- a/fluxer_rexctl/internal/instance/envvars.go
+++ b/fluxer_rexctl/internal/instance/envvars.go
@@ -65,7 +65,7 @@ var envVars = []envVar{
{"FLUXER_APP_ORIGIN_ALIASES", "address", "More web app origins, separated by commas, for an instance that serves the web app on more than one hostname. Each must be an http or https origin. The API allows each one through CORS and accepts it for sign-in handoff. For passkeys on these origins, list them and the web app origin in FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS."},
{"FLUXER_API_ENDPOINT", "address", "The public base URL of the API. When it's empty, Fluxer uses the public origin followed by /api."},
{"FLUXER_API_CLIENT_ENDPOINT", "address", "The API base URL Fluxer hands to clients. When it's empty, Fluxer uses the public origin followed by /api."},
- {"FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT", "address", "The public API base URL Fluxer lists in instance discovery as `api_public`. When it's empty, Fluxer uses FLUXER_API_ENDPOINT. Webhooks, signed links and federation always use FLUXER_API_ENDPOINT."},
+ {"FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT", "address", "The public API base URL Fluxer lists in instance discovery as `api_public`. The ActivityPub actor and its key ID use the same address, so its host must serve /.well-known/webfinger, and changing it on an instance with a signing key gives remote servers a new actor. When it's empty, Fluxer uses FLUXER_API_ENDPOINT. Webhooks, signed links and Bluesky sign-in always use FLUXER_API_ENDPOINT."},
{"FLUXER_APP_ENDPOINT", "address", "The address of the web app, which Fluxer allows through CORS and uses in links. When it's empty, Fluxer uses the public origin."},
{"FLUXER_GATEWAY_ENDPOINT", "address", "The public WebSocket URL of the gateway, starting with `ws` or `wss`. When it's empty, Fluxer uses `wss` on the public host followed by /gateway, or `ws` when the public scheme is `http`."},
{"FLUXER_MEDIA_ENDPOINT", "address", "The public address of the media proxy. When it's empty, Fluxer uses the public origin followed by /media."},
diff --git a/fluxer_rexctl/internal/instance/shipped.json b/fluxer_rexctl/internal/instance/shipped.json
index 339489933..bd28e1b75 100644
--- a/fluxer_rexctl/internal/instance/shipped.json
+++ b/fluxer_rexctl/internal/instance/shipped.json
@@ -62,6 +62,7 @@
"98c3a38cf6180d1e925b16f4fb5160f27d2a7b399d928d7fa834555e658c843f",
"98e840268063fcc8f285364dc8b0098e416621ea99e9a92ab986661200f122e9",
"9b4da1d640c6c7882cc583f5fcb04a7a3c478a3b167ceefe9a1fdc8613e7a547",
+ "9d98d16d138403a60ec3d883edb068a6ee6a1895ded5fa7de8a5ce1fb8e9fa11",
"9ddb7e697174484b2411c6b7239e73374200512597bd5de9f9654ff796e3a39a",
"a0fcbc346ae2c9038294e921fa0cd53c0dbabfc92c005e72825b22c6f4c562f3",
"a3b0de3f98f20af674ba28457062092e2efa64744ff56d3b82947ec2148e629b",
diff --git a/fluxer_rexctl/internal/stack/files/.env.example b/fluxer_rexctl/internal/stack/files/.env.example
index b4f8fa7fa..8f1f31363 100644
--- a/fluxer_rexctl/internal/stack/files/.env.example
+++ b/fluxer_rexctl/internal/stack/files/.env.example
@@ -248,8 +248,11 @@ FLUXER_VAPID_PRIVATE_KEY=
# FLUXER_API_CLIENT_ENDPOINT=
# The public API base URL Fluxer lists in instance discovery as api_public.
-# When it's empty, Fluxer uses FLUXER_API_ENDPOINT. Webhooks, signed links and
-# federation always use FLUXER_API_ENDPOINT.
+# The ActivityPub actor and its key ID use the same address, so its host must
+# serve /.well-known/webfinger, and changing it on an instance with a signing
+# key gives remote servers a new actor. When it's empty, Fluxer uses
+# FLUXER_API_ENDPOINT. Webhooks, signed links and Bluesky sign-in always use
+# FLUXER_API_ENDPOINT.
# rexctl: rexctl config set FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT
# FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT=