Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions api/admin_ui/src/components/PluginMarketplace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useState } from 'react';
import { Box, Typography, TextField, InputAdornment, Grid, Card, CardContent } from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';

/**
* Minimal placeholder for the Admin Console Plugin Marketplace.
* - Strict TypeScript compliant (no unused vars)
* - Not wired into the App shell yet; safe to compile
* - No provider name checks; trait‑gated wiring will come in later PRs
*/
export default function PluginMarketplace(): JSX.Element {
const [query, setQuery] = useState('');

return (
<Box sx={{ px: { xs: 1, sm: 2, md: 3 }, py: 2 }}>
<Typography variant="h4" sx={{ mb: 2 }}>
Plugin Marketplace
</Typography>

<TextField
fullWidth
placeholder="Search plugins…"
value={query}
onChange={(e) => setQuery(e.target.value)}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
sx={{ mb: 3 }}
/>

<Grid container spacing={2}>
{/* Empty state placeholder; results will be populated in later PRs */}
<Grid item xs={12}>
<Card variant="outlined">
<CardContent>
<Typography color="text.secondary">
Marketplace results will appear here. Use traits to gate provider‑specific UI.
</Typography>
</CardContent>
</Card>
</Grid>
</Grid>
</Box>
);
}

8 changes: 8 additions & 0 deletions api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ async def v4_config_flush_cache(scope: Optional[str] = None):
# Non-fatal if health monitoring deps missing
pass

# Admin marketplace (Phase 4; disabled by default)
try:
from .routers import admin_marketplace as _marketplace
app.include_router(_marketplace.router)
except Exception:
# Non-fatal if marketplace router cannot be imported
pass

# Webhook hardening router (DLQ + idempotency)
try:
from .routers import webhooks_v2 as _webhooks_v2
Expand Down
39 changes: 39 additions & 0 deletions api/app/routers/admin_marketplace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import annotations

import os
from typing import Optional
from fastapi import APIRouter, Depends, Header, HTTPException
from api.app.config import settings
from api.app.auth import verify_db_key


def require_admin(x_api_key: Optional[str] = Header(default=None)):
"""Minimal admin auth dependency for marketplace endpoints.
- Accepts env bootstrap API key
- Or a DB-backed key with scope keys:manage
"""
if settings.api_key and x_api_key == settings.api_key:
return {"admin": True, "key_id": "env"}
info = verify_db_key(x_api_key)
if not info or ("keys:manage" not in (info.get("scopes") or [])):
raise HTTPException(401, detail="Admin authentication failed")
return info


router = APIRouter(prefix="/admin/marketplace", tags=["AdminMarketplace"], dependencies=[Depends(require_admin)])


@router.get("/plugins")
def list_plugins():
"""List available plugins in the marketplace (disabled by default).

Gate with ADMIN_MARKETPLACE_ENABLED=false by default to avoid exposing in prod
until features are complete.
"""
enabled = os.getenv("ADMIN_MARKETPLACE_ENABLED", "false").lower() in {"1", "true", "yes"}
if not enabled:
# Hide endpoint when disabled to avoid confusing operators
raise HTTPException(404, detail="Not found")
# Placeholder: will be populated via trait‑aware registry in later PRs
return {"plugins": []}

Loading