feat(modules): RequireModule middleware to gate route groups #98

Closed
opened 2026-02-14 19:46:18 +00:00 by forbes · 0 comments
Owner

Ref: docs/MODULES.md §4, §3, §11 step 5

Implement RequireModule middleware and wrap each optional module's route group.

Middleware behavior:
When a module is disabled, all its routes return 404 with {"error": "module '<id>' is not enabled"}.

func RequireModule(id string) func(http.Handler) http.Handler

Route groups to wrap (per §3):

  • auth — login/logout, OIDC callbacks, /api/auth/*, settings token routes
  • projects/api/projects/*, item-project tagging endpoints
  • audit/api/audit/*
  • odoo/api/integrations/odoo/*
  • jobs/api/jobs/*, /api/job-definitions/*, /api/runners/*, /api/runner/*
  • dag/api/items/{partNumber}/dag/*
  • freecad — no routes currently, but future-proofed

When auth is disabled:
All routes are open and a synthetic dev admin user is injected (existing behavior).

Additional disabled-module behavior:

  • SSE events from disabled modules are not broadcast
  • Background goroutines (job sweepers, runner heartbeat) are not started
  • Database tables are NOT dropped — data preserved for re-enablement

Depends on #96.

**Ref:** docs/MODULES.md §4, §3, §11 step 5 Implement `RequireModule` middleware and wrap each optional module's route group. **Middleware behavior:** When a module is disabled, all its routes return `404` with `{"error": "module '<id>' is not enabled"}`. ```go func RequireModule(id string) func(http.Handler) http.Handler ``` **Route groups to wrap (per §3):** - `auth` — login/logout, OIDC callbacks, `/api/auth/*`, settings token routes - `projects` — `/api/projects/*`, item-project tagging endpoints - `audit` — `/api/audit/*` - `odoo` — `/api/integrations/odoo/*` - `jobs` — `/api/jobs/*`, `/api/job-definitions/*`, `/api/runners/*`, `/api/runner/*` - `dag` — `/api/items/{partNumber}/dag/*` - `freecad` — no routes currently, but future-proofed **When `auth` is disabled:** All routes are open and a synthetic `dev` admin user is injected (existing behavior). **Additional disabled-module behavior:** - SSE events from disabled modules are not broadcast - Background goroutines (job sweepers, runner heartbeat) are not started - Database tables are NOT dropped — data preserved for re-enablement Depends on #96.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#98