Aller au contenu

Routage inter-app — Synthèse SLY

Synthèse opérationnelle pour les développeurs DYNORS. Pour la spec complète, voir docs/SLY_SYNTHESE_INTERAPP.md.


Architecture globale

┌───────────────────────────────────────────────────────────────────┐
│                    APPELS INTERNES DYNORS                         │
│                                                                   │
│  SuperGest ─────────────────────────────────────────────►        │
│  Mediconnect ──────────────────────────────────────────►         │
│  TRACIUM ─────────────────────────────────────────────►          │
│  RAGNAR ──────────────────────────────────────────────►          │
│                                              ┌───────────────┐   │
│                                              │  SelebeYone   │   │
│                                              │     (SLY)     │   │
│                                              │  sly.dynors   │   │
│                                              └───────┬───────┘   │
│                                                      │           │
│                         ┌────────────────────────────┼─────────┐ │
│                         │                            │         │ │
│                      FISCAL                       BOOKS     TRACIUM │
│                      NOTIFY                      DAWALALE   etc. │
└───────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────┐
│                    APPELS B2B (partenaires)                      │
│                                                                  │
│  Partenaire DGI, ERP client, Tiers certifié                      │
│       │                                                          │
│       ▼  X-Sly-Pass (token B2B)                                  │
│  SLY valide le scope, rate-limit, tenant                         │
│       │                                                          │
│       ▼  réseau privé (backends non exposés)                     │
│  FISCAL · BOOKS · TRACIUM                                        │
└──────────────────────────────────────────────────────────────────┘

Matrice d'appels inter-app

App appelante App cible Chemin SLY Module client
SuperGest FISCAL /fiscal/** FiscalClientInterAppCallService
SuperGest TRACIUM /tracium/** TraciumClient
Mediconnect FISCAL /fiscal/** FiscalClient
TRACIUM gateway FISCAL /fiscal/** FiscalClient
RAGNAR FISCAL /fiscal/** FiscalClient
RAGNAR notify /notify/** NotifyClient
TAKKU FISCAL /fiscal/** FiscalClient
Toute app BOOKS /books/** BooksClient
Toute app notify /notify/** NotifyClient

Headers propagés par SLY

Header Posé par Lu par
X-Source-App App appelante via InterAppCallService SLY, backend cible
X-Tenant-Id App appelante via InterAppCallService SLY, backend cible
X-Request-Id InterAppCallService (UUID) SLY, backend cible
X-Sly-Timestamp SLY (SlyForwardSigningFilter) SlyTransitFilter backend
X-Sly-Signature SLY (SlyForwardSigningFilter) SlyTransitFilter backend
X-Sly-Pass Partenaire B2B SLY uniquement

Signature de transit HMAC

Voir gateway-selebeyone.md#signature-de-transit pour le détail.

En résumé :

HMAC-SHA256( SLY_FORWARD_SECRET, "<ts>:<requestId>:<path>" )
  • SLY calcule et injecte X-Sly-Timestamp + X-Sly-Signature sur chaque requête forwardée.
  • Le backend vérifie via SlyTransitFilter (fourni par dynors-commons).
  • Fenêtre anti-replay : 30 secondes par défaut.

Implémenter un client inter-app

Toujours créer un client dédié (ex. FiscalClient) qui encapsule InterAppCallService :

@Service
@RequiredArgsConstructor
public class FiscalClient {

    private final InterAppCallService interApp;

    public FiscalCertifyResponse certify(String tenantCode, FiscalCertifyPayload payload) {
        return interApp.post(
                "/fiscal/api/v1/fiscal/certify",
                payload,
                FiscalCertifyResponse.class,
                tenantCode
        );
    }
}

Ne jamais instancier RestTemplate, WebClient ou HttpClient directement pour appeler une app DYNORS.


Vérifier qu'une requête vient bien de SLY (côté backend)

  1. Ajouter dynors-commons (version BOM) à la dépendance.
  2. Enregistrer SlyTransitFilter :
@Bean
FilterRegistrationBean<SlyTransitFilter> slyTransit(
        @Value("${dynors.interapp.sly-forward-secret:}") String secret) {
    var filter = new SlyTransitFilter(secret, 30_000L,
            Set.of("/actuator/health", "/v3/api-docs"));
    var reg = new FilterRegistrationBean<>(filter);
    reg.addUrlPatterns("/api/*");
    reg.setOrder(Ordered.HIGHEST_PRECEDENCE + 10);
    return reg;
}
  1. Ajouter SLY_FORWARD_SECRET en variable d'environnement (même valeur que celle de SLY).

Références