/** * Label Studio Integration Routes * * This module registers all Label Studio-related routes: * - Webhook handler for Label Studio events (PUBLIC) * - SSO authentication endpoint (PRIVATE - requires authentication) * * ## Subdomain Cookie Sharing Architecture: * This integration uses subdomain-based cookie sharing instead of proxying. * - Backend gets JWT token from Label Studio and sets shared domain cookie * - Frontend loads Label Studio directly (not through proxy) * - Cookie is automatically sent with all subdomain requests */ import Koa from 'koa' import Router from 'koa-router' import { webhookRouter } from './route/webhook' import { ssoRouter } from './route/label-studio-sso' // Public routes - No authentication required process.on('bootstrap-module-global-public-route' as any, (_app: Koa, routes: Router) => { /* * Register webhook routes (Label Studio → Things Factory) * These must be public so Label Studio can send events */ routes.use(webhookRouter.routes(), webhookRouter.allowedMethods()) }) // Private routes - Authentication required process.on('bootstrap-module-domain-private-route' as any, (_app: Koa, routes: Router) => { /* * Register Label Studio SSO routes * This requires authentication - ctx.state.user will be available */ routes.use(ssoRouter.routes(), ssoRouter.allowedMethods()) })