smart_ide/docs/API/global-api.md
Nicolas Cantu 0af507143a Add smart-ide-global API layer, SSO delegates proxy, .logs access logs
- New smart-ide-global-api (127.0.0.1:37149): internal bearer, upstream proxy, X-OIDC forward
- SSO gateway calls global API with GLOBAL_API_INTERNAL_TOKEN; logs to .logs/sso-gateway/
- Aggregated config example, docs, VERSION 0.0.2, claw proxy local URL hint
2026-04-03 23:08:52 +02:00

54 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# API — smart-ide-global-api
Écoute par défaut : **`127.0.0.1:37149`**. Configuration : `services/smart-ide-global-api/.env.example`, agrégat [config/services.local.env.example](../../config/services.local.env.example).
## Rôle
Agrégateur HTTP **interne** : reçoit les requêtes authentifiées par `Authorization: Bearer <GLOBAL_API_INTERNAL_TOKEN>` (fourni par `smart-ide-sso-gateway`), relaie vers chaque micro-service avec son **jeton technique** et propage les en-têtes `X-OIDC-Sub` / `X-OIDC-Email` lorsquils sont présents.
Les navigateurs et applications utilisateur ne doivent **pas** appeler ce port directement : passer par la **passerelle SSO** (`/proxy/<clé>/...`).
## Authentification
| Route | Auth |
|-------|------|
| `GET /health` | Aucune |
| Toutes les autres | `Authorization: Bearer` égal à `GLOBAL_API_INTERNAL_TOKEN` |
## Endpoints
### `GET /health`
Réponse `200` : `{ "status": "ok", "service": "smart-ide-global-api" }`.
### `GET /v1/upstreams`
Liste les clés damont : `{ "upstreams": [ "orchestrator", ... ] }` (même liste que côté SSO).
### Proxy — `ANY /v1/upstream/<upstream_key>/<path>`
- **`<upstream_key>`** : `orchestrator`, `repos_devtools`, `ia_dev_gateway`, `anythingllm_devtools`, `tools_bridge`, `langextract`, `regex_search`, `claw_proxy`, `local_office`.
- **`<path>`** : transmis à lURL de base du service (ex. `/v1/upstream/orchestrator/v1/...``http://127.0.0.1:37145/v1/...`).
- **Corps** : relayé (limite `GLOBAL_API_MAX_BODY_BYTES`, défaut 32 MiB).
- **Erreurs** : `401` si Bearer interne absent ou incorrect ; `404` si clé inconnue ; `503` si `local_office` sans `LOCAL_OFFICE_API_KEY`.
## Journaux
Fichier **`.logs/global-api/access.log`** : lignes JSON (`ts`, `method`, `path`, `upstream`, `status`, `durationMs`, `oidcSub` si présent).
## Variables denvironnement
| Variable | Rôle |
|----------|------|
| `GLOBAL_API_HOST` / `GLOBAL_API_PORT` | Bind HTTP |
| `GLOBAL_API_INTERNAL_TOKEN` | Obligatoire — secret partagé avec la passerelle SSO |
| `GLOBAL_API_MAX_BODY_BYTES` | Taille max du corps |
| `SMART_IDE_MONOREPO_ROOT` | Racine monorepo pour `.logs/` (sinon déduction depuis le module) |
Jetons et hôtes des micro-services : mêmes noms que dans `config/services.local.env.example`.
## Voir aussi
- [sso-gateway-api.md](./sso-gateway-api.md)
- [sso-gateway-service.md](../features/sso-gateway-service.md)