Register Module Foundry service handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-07-23 13:53:56 +03:00
parent 332e097116
commit 24d01fc813
4 changed files with 158 additions and 1 deletions
+34 -1
View File
@@ -3347,6 +3347,7 @@ function getAppCatalog() {
url: getServiceUrl(service),
openUrl: getServiceUrl(service),
launchTargetUrl: getServiceLaunchTargetUrl(service),
authHandoffPath: service.authHandoffPath || null,
status: service.status ?? "disabled",
provider: "authentik",
requiredGroups,
@@ -3405,7 +3406,12 @@ function specialRequiredGroups(serviceOrSlug) {
}
function getServiceUrl(service) {
if (service.slug === "task-manager" || isEngineServiceSlug(service.slug) || isBimViewerServiceSlug(service.slug)) {
if (
service.slug === "task-manager" ||
isEngineServiceSlug(service.slug) ||
isBimViewerServiceSlug(service.slug) ||
service.authHandoffPath
) {
return `/api/services/${encodeURIComponent(service.slug)}/launch`;
}
@@ -3413,6 +3419,14 @@ function getServiceUrl(service) {
}
function getServiceLaunchTargetUrl(service) {
// Catalog entries replace `url` with the Launcher launch route for services
// that need a handoff. Keep their external origin separately so a relative
// handoff path is always resolved against the target application, never the
// internal `/api/services/:slug/launch` route.
if (service?.launchTargetUrl) {
return service.launchTargetUrl;
}
if (isEngineServiceSlug(service?.slug)) {
return service.launchUrl || service.url || getEnginePublicBaseUrl();
}
@@ -3500,6 +3514,25 @@ function redirectToServiceLaunchTarget(res, serviceSlug, runtimeContext, app, re
return;
}
// Module Foundry and future internal services use the same Launcher-owned
// session contract as BIM. The path is service metadata, so the launcher
// does not grow a separate authentication mechanism per module.
const handoffPath = String(app?.authHandoffPath || "").trim();
if (handoffPath) {
const handoffToken = createServiceHandoff(serviceSlug, runtimeContext.user, { launcherSessionId: session?.id });
const targetUrl = new URL(handoffPath, getServiceLaunchTargetUrl(app));
const nextPath = sanitizeReturnTo(returnTo);
targetUrl.searchParams.set("token", handoffToken);
if (nextPath && nextPath !== "/") {
targetUrl.searchParams.set("next_path", nextPath);
}
res.redirect(targetUrl.toString());
return;
}
if (serviceSlug !== "task-manager") {
res.redirect(app.openUrl || app.url || "/");
return;