Skip to content

feat: Implement Controllers for Middleware Management API #197

Closed as not planned

Description

@keshxvdayal

Implement complete backend controller logic for the middleware management REST API. This includes all seven HTTP request handlers with CRUD operations, order management, security validation, Pydantic models, and MongoDB integration. Controllers handle pagination, filtering, soft/hard deletes, and code validation using AST parsing for security checks.

Activity

  1. keshxvdayal commented on Jan 27, 2026

    @keshxvdayal
    ContributorAuthor

    Middleware Management API Controllers - Implementation Plan

    Objective

    Implement complete backend controller logic for the middleware management REST API, enabling dynamic middleware configuration through seven CRUD endpoints.

    Deliverables

    1. Core Controllers (controllers.py)

    • ListMiddlewares: GET endpoint with pagination, filtering (enabled/source), and sorting support
    • AddMiddleware: POST endpoint with automatic order assignment, duplicate detection, and GitHub code fetching
    • GetMiddleware: GET single middleware by ID with complete details
    • UpdateMiddleware: PUT endpoint with order conflict resolution and immutable class_path enforcement
    • DeleteMiddleware: DELETE with soft delete default and hard delete via ?force=true parameter
    • ReorderMiddlewares: PUT bulk reorder operation for entire middleware stack
    • ValidateMiddleware: POST validation endpoint using AST parsing for security checks

    2. Data Models (models.py)

    • Pydantic schemas: MiddlewareCreate, MiddlewareUpdate with field validation
    • Input constraints: name length (1-255), order ≥ 0, limit (1-100)

    3. Security Validation (validation.py)

    • AST-based syntax checking and forbidden import detection (os, sys, subprocess, eval, exec)
    • Interface compliance: verify AbstractMiddleware inheritance and apply_middleware() method
    • GitHub integration for remote middleware fetching

    4. Database Integration

    • MongoDB collection: taskStore.middlewares with unique indexes on name/class_path
    • Smart order management: automatic shifting on insert/update/delete operations
    • Timestamp tracking: auto-generated created_at and updated_at fields

    5. Testing

    • Unit tests for models, validation, CRUD operations, and order management
    • Integration testing with curl commands for all seven endpoints

    Technical Approach

    • Use Connexion for automatic request/response validation via OpenAPI spec
    • Implement ObjectId to string conversion for JSON serialization
    • Soft delete preserves audit trail; hard delete requires explicit force flag
    • Immutable class_path and source fields prevent code substitution attacks

    Dependencies

    External: FOCA, Connexion, Flask, MongoDB, Pydantic, PyMongo, requests
    Internal: pro_tes.middleware.abstract_middleware, database connection utilities

    Success Criteria

    ✅ All 7 endpoints functional and returning correct HTTP status codes
    ✅ Unit tests passing with 100% controller coverage
    ✅ Response validation passing against OpenAPI schema
    ✅ No breaking changes to existing TES API functionality

    Pull Request for this issue

  2. added
    status: blocked
    on Oct 22, 2026
  3. uniqueg commented on Oct 24, 2026

    @uniqueg
    Member

    Closing as not planned.

    We decided against a runtime management API for task plugins: operators
    manage the available plugins and the default pipeline by configuration
    only (versioned, reviewed and rolled out like any other config change),
    and no code is installed at runtime. Clients can still choose the
    pipeline per task, from the plugins the operator allowed, via a reserved
    task tag (gateway.pipeline, see #218).

    The plugin engine moves into FOCA (foca.plugins, FOCA 0.18.0, elixir-cloud-aai/foca#485),
    so proTES, proWES and later gateways share it; proTES adopts it in
    #321. Thanks to everyone who worked on the management design: its goals
    (admin control, discoverability, per-task choice) are covered by the
    config, GET /plugins and the per-task tags.

  4. uniqueg commented on Oct 26, 2026

    @uniqueg
    Member

    Closing note: proTES moves its task middlewares to the FOCA plugin engine (elixir-cloud-aai/foca#485, in FOCA 0.18.0; proTES migration in #194). By design, plugins are managed by configuration only: admins enable, pin and order them in the app config, and there is no runtime API to install, enable or disable them. A middleware management API with controllers is therefore not planned. Available plugins can be listed read-only via GET /plugins and in /service-info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: blocked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions