Skip to content

fix(personality): save/create fails in SLM admin - JWT mismatch + add new personalities #1145

Closed

Description

@mrveiss

Problem

Root Cause

The SLM frontend calls /autobot-api/personality/* which nginx proxies to the main backend (172.16.168.20:8443/api/personality/*).

The mutating endpoints (PUT, POST, DELETE) require check_admin_permission which validates a main backend JWT. But the SLM frontend sends its own SLM JWT (signed with SLM_SECRET_KEY), which the main backend cannot verify — returning 401.

GET requests work because they have no auth requirement.

Solution

  1. Add SLM backend personality proxy routes at /api/personality/* that:
    • Validate the SLM JWT and require admin for mutations
    • Forward all requests to the main backend using a shared X-Internal-API-Key header
  2. Add X-Internal-API-Key check to main backend check_admin_permission
  3. Change frontend API_BASE from /autobot-api/personality to /api/personality (SLM backend)

Subtasks

  • Add AUTOBOT_INTERNAL_API_KEY to main backend auth_middleware check_admin_permission
  • Add AUTOBOT_INTERNAL_API_KEY and AUTOBOT_BACKEND_URL to SLM backend config
  • Create autobot-slm-backend/api/personality_proxy.py (proxy router)
  • Register personality proxy router in SLM backend main.py
  • Update SLM frontend API_BASE in usePersonality.ts
  • Generate and deploy AUTOBOT_INTERNAL_API_KEY to .env on both .19 and .20
  • Rebuild SLM frontend and deploy to .19

Acceptance Criteria

  • Save personality settings succeeds in SLM admin
  • Create new personality succeeds in SLM admin
  • Duplicate profile works
  • Delete profile works
  • No regressions in main frontend personality management

Activity

  1. mrveiss commented on Feb 23, 2026

    @mrveiss
    OwnerAuthor

    ✅ Implemented and deployed in commit 4e4ee87.

    Root Cause

    The SLM admin frontend was sending SLM JWT tokens (signed with SLM_SECRET_KEY) directly to the main backend's personality API via the nginx /autobot-api/ proxy. The main backend validates JWTs with its own SECRET_KEY and uses different claim names (username/role vs sub/admin), so all mutating requests (PUT/POST/DELETE) were rejected with 401.

    Changes

    • autobot-slm-backend/api/personality_proxy.py (new): Catch-all proxy router at /api/personality/*. Validates SLM JWT for all requests; requires admin: true claim for mutations. Forwards to main backend with X-Internal-API-Key header.
    • autobot-slm-backend/main.py: Register new personality_proxy_router at /api.
    • autobot-backend/auth_middleware.py: Added X-Internal-API-Key check — if header matches AUTOBOT_INTERNAL_API_KEY env var, grant admin access without requiring a main-backend JWT.
    • autobot-slm-frontend/src/composables/usePersonality.ts: Changed API_BASE from /autobot-api/personality to /api/personality to route through the SLM backend proxy.

    Deployment

    • AUTOBOT_INTERNAL_API_KEY set on both .20 (main backend) and .19 (SLM backend via /etc/autobot/slm-secrets.env)
    • AUTOBOT_BACKEND_URL=https://172.16.168.20:8443 set on .19
    • Both services restarted and confirmed healthy
    • SLM frontend rebuilt and deployed to .19

    Verification: Both GET (profile list) and POST/PUT/DELETE (save, create, activate) now go through the SLM backend proxy, which validates the SLM admin JWT before forwarding.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions