chore: build
This commit is contained in:
@@ -173,6 +173,8 @@ func main() {
|
||||
// prolongée ; supprimés à l'échéance (voir internal/projects).
|
||||
projectSvc := projects.NewService(projectStore, helmProv, projects.Config{
|
||||
Domain: cfg.VitrineDomain,
|
||||
// Un client ne peut pas revendiquer un domaine d'Omnex (démos).
|
||||
ReservedDomains: []string{cfg.DemoDomain},
|
||||
})
|
||||
go projectSvc.RunExpirationLoop(context.Background(), 5*time.Minute)
|
||||
|
||||
|
||||
@@ -961,9 +961,15 @@ func (h *HelmProvisioner) installChartFrom(chartsDir, namespace, chartName strin
|
||||
// (helm upgrade --install) — pour l'infra partagée (Traefik), appelée à
|
||||
// chaque démarrage de l'API et qui ne doit pas échouer si déjà en place.
|
||||
func (h *HelmProvisioner) upgradeInstallChart(namespace, release, chartName string, values map[string]interface{}) error {
|
||||
return h.upgradeInstallChartFrom(h.chartsDir, namespace, release, chartName, values)
|
||||
}
|
||||
|
||||
// upgradeInstallChartFrom : comme upgradeInstallChart, pour un dossier de
|
||||
// charts donné (démos : h.chartsDir ; projets vitrine : h.vitrineChartsDir).
|
||||
func (h *HelmProvisioner) upgradeInstallChartFrom(chartsDir, namespace, release, chartName string, values map[string]interface{}) error {
|
||||
args := []string{
|
||||
"upgrade", release,
|
||||
filepath.Join(h.chartsDir, chartName),
|
||||
filepath.Join(chartsDir, chartName),
|
||||
"--install",
|
||||
"--namespace", namespace,
|
||||
"--wait",
|
||||
|
||||
@@ -189,6 +189,52 @@ func buildProjectState(pods []corev1.Pod, usage map[string][2]int64) ResourceSta
|
||||
return state
|
||||
}
|
||||
|
||||
// ProjectDomainSpec : domaine public d'un projet vitrine déjà déployé.
|
||||
type ProjectDomainSpec struct {
|
||||
Namespace string
|
||||
Host string // hôte par défaut (<namespace>.<domaine vitrine>), toujours servi
|
||||
// CustomDomain : domaine du client, servi en plus de Host. "" = aucun.
|
||||
CustomDomain string
|
||||
// URL publique à utiliser pour les liens absolus du backend (médias).
|
||||
URL string
|
||||
}
|
||||
|
||||
// UpdateProjectDomain applique le domaine d'un projet : l'IngressRoute sert
|
||||
// l'hôte par défaut ET le domaine du client (le site reste joignable sur son
|
||||
// adresse d'origine tant que le DNS ou le certificat du domaine ne sont pas
|
||||
// prêts), puis le backend reprend l'URL publique pour ses liens de médias.
|
||||
// Idempotent : le service peut le rejouer après un échec partiel.
|
||||
func (h *HelmProvisioner) UpdateProjectDomain(s ProjectDomainSpec) error {
|
||||
var extra []string
|
||||
if s.CustomDomain != "" {
|
||||
extra = []string{s.CustomDomain}
|
||||
}
|
||||
ingress := h.buildVitrineIngressRouteValues(ProjectSpec{Namespace: s.Namespace, Host: s.Host}, extra...)
|
||||
if err := h.upgradeInstallChartFrom(h.vitrineChartsDir, s.Namespace, s.Namespace+"-ingressroute", "ingressroute", ingress); err != nil {
|
||||
return fmt.Errorf("mise à jour ingressroute: %w", err)
|
||||
}
|
||||
|
||||
// Les valeurs de la release (secrets compris) sont relues telles que
|
||||
// déployées : seul MEDIA_LOCAL_BASE_URL change. Le changement de ConfigMap
|
||||
// relance le Deployment (annotation checksum/config du chart).
|
||||
backend := s.Namespace + "-backend"
|
||||
values, err := h.getReleaseValues(s.Namespace, backend)
|
||||
if err != nil {
|
||||
return fmt.Errorf("lecture des valeurs du backend: %w", err)
|
||||
}
|
||||
env, _ := values["env"].(map[string]interface{})
|
||||
if env == nil {
|
||||
env = map[string]interface{}{}
|
||||
}
|
||||
env["MEDIA_LOCAL_BASE_URL"] = s.URL + "/uploads"
|
||||
values["env"] = env
|
||||
if err := h.upgradeInstallChartFrom(h.vitrineChartsDir, s.Namespace, backend, "backend", values); err != nil {
|
||||
return fmt.Errorf("mise à jour du backend: %w", err)
|
||||
}
|
||||
log.Printf("Domaine du projet %s mis à jour: %s", s.Namespace, s.URL)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *HelmProvisioner) buildVitrinePostgresValues(password string) map[string]interface{} {
|
||||
// Nom de base et utilisateur : défauts du chart (vitrine_db / postgres),
|
||||
// alignés sur database.name / database.user du chart backend.
|
||||
@@ -247,11 +293,17 @@ func (h *HelmProvisioner) buildVitrineFrontendValues() map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HelmProvisioner) buildVitrineIngressRouteValues(p ProjectSpec) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
// buildVitrineIngressRouteValues : extraHosts = domaines personnalisés du
|
||||
// client, servis en plus de l'hôte par défaut p.Host.
|
||||
func (h *HelmProvisioner) buildVitrineIngressRouteValues(p ProjectSpec, extraHosts ...string) map[string]interface{} {
|
||||
values := map[string]interface{}{
|
||||
"host": p.Host,
|
||||
"traefikNamespace": sharedTraefikNamespace,
|
||||
"backend": map[string]interface{}{"serviceName": vitrineBackendService(p.Namespace)},
|
||||
"frontend": map[string]interface{}{"serviceName": vitrineFrontendService(p.Namespace)},
|
||||
}
|
||||
if len(extraHosts) > 0 {
|
||||
values["extraHosts"] = extraHosts
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package demos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -64,9 +65,16 @@ func TestVitrineValuesRenderWithCharts(t *testing.T) {
|
||||
"name: " + vitrineFrontendService(p.Namespace) + "\n",
|
||||
"tls: {}", // certificat servi par le TLSStore, pas par projet
|
||||
}},
|
||||
// Domaine personnalisé : servi EN PLUS de l'hôte par défaut, sur les
|
||||
// trois routes (API, médias, frontend).
|
||||
{"ingressroute", h.buildVitrineIngressRouteValues(p, "boutique.client.fr"), []string{
|
||||
"(Host(`vitrine-ab12cd34.vitrine-omnex.club`) || Host(`boutique.client.fr`)) && PathPrefix(`/api/`)",
|
||||
"(Host(`vitrine-ab12cd34.vitrine-omnex.club`) || Host(`boutique.client.fr`)) && PathPrefix(`/uploads/`)",
|
||||
"match: Host(`vitrine-ab12cd34.vitrine-omnex.club`) || Host(`boutique.client.fr`)\n",
|
||||
}},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.chart, func(t *testing.T) {
|
||||
for i, c := range cases {
|
||||
t.Run(fmt.Sprintf("%s-%d", c.chart, i), func(t *testing.T) {
|
||||
raw, err := yaml.Marshal(c.values)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/omnex/control-plane/api/internal/demos"
|
||||
)
|
||||
|
||||
type Handler struct{ svc *Service }
|
||||
@@ -21,6 +23,12 @@ type createRequest struct {
|
||||
AdminNumber int `json:"admin_number" binding:"omitempty,min=1,max=20"`
|
||||
}
|
||||
|
||||
type domainRequest struct {
|
||||
// Domain : nom d'hôte sans protocole ni chemin (ex. "boutique.client.fr").
|
||||
// Vide = retire le domaine personnalisé.
|
||||
Domain string `json:"domain" binding:"omitempty,max=253"`
|
||||
}
|
||||
|
||||
type extendRequest struct {
|
||||
Months int `json:"months" binding:"required,min=1,max=12"`
|
||||
}
|
||||
@@ -29,10 +37,11 @@ func (h *Handler) writeError(c *gin.Context, err error) {
|
||||
switch {
|
||||
case errors.Is(err, ErrNotFound):
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": err.Error()})
|
||||
case errors.Is(err, ErrNotExtendable):
|
||||
case errors.Is(err, ErrNotExtendable), errors.Is(err, ErrNotReady), errors.Is(err, ErrDomainTaken):
|
||||
c.JSON(http.StatusConflict, gin.H{"error": err.Error()})
|
||||
case errors.Is(err, ErrInvalidMonths), errors.Is(err, ErrInvalidClient), errors.Is(err, ErrInvalidAdmin),
|
||||
errors.Is(err, ErrWeakAdminPass), errors.Is(err, ErrInvalidAdminSize):
|
||||
errors.Is(err, ErrWeakAdminPass), errors.Is(err, ErrInvalidAdminSize), errors.Is(err, ErrDomainReserved),
|
||||
errors.Is(err, demos.ErrInvalidDomain):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
default:
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "erreur serveur"})
|
||||
@@ -87,6 +96,22 @@ func (h *Handler) Details(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"namespace": p.Namespace, "state": state})
|
||||
}
|
||||
|
||||
// SetDomain : POST /projects/:id/domain {"domain": "boutique.client.fr"} —
|
||||
// définit le domaine personnalisé du client ; domaine vide = le retire.
|
||||
func (h *Handler) SetDomain(c *gin.Context) {
|
||||
var req domainRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "requête invalide"})
|
||||
return
|
||||
}
|
||||
p, err := h.svc.SetDomain(c.Param("id"), req.Domain)
|
||||
if err != nil {
|
||||
h.writeError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, p)
|
||||
}
|
||||
|
||||
// Get : GET /projects/:id.
|
||||
func (h *Handler) Get(c *gin.Context) {
|
||||
p, err := h.svc.Get(c.Param("id"))
|
||||
|
||||
@@ -25,6 +25,7 @@ func newTestRouter(t *testing.T) (*gin.Engine, *fakeProv) {
|
||||
r.DELETE("/projects/:id", h.Delete)
|
||||
r.POST("/projects/:id/extend", h.Extend)
|
||||
r.GET("/projects/:id/details", h.Details)
|
||||
r.POST("/projects/:id/domain", h.SetDomain)
|
||||
return r, prov
|
||||
}
|
||||
|
||||
@@ -135,3 +136,36 @@ func TestHandlerDetails(t *testing.T) {
|
||||
t.Errorf("erreur cluster : %d %s (500 sans détail interne attendu)", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerSetDomain_StatusCodes(t *testing.T) {
|
||||
r, prov := newTestRouter(t)
|
||||
w := do(r, "POST", "/projects", body("1"))
|
||||
var created Project
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &created); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
<-prov.provisioned
|
||||
path := "/projects/" + created.ID + "/domain"
|
||||
|
||||
cases := []struct {
|
||||
name, path, body string
|
||||
want int
|
||||
}{
|
||||
{"valide", path, `{"domain":"boutique.client.fr"}`, http.StatusOK},
|
||||
{"retrait", path, `{"domain":""}`, http.StatusOK},
|
||||
{"format invalide", path, `{"domain":"pas un domaine"}`, http.StatusBadRequest},
|
||||
{"domaine omnex", path, `{"domain":"x.vitrine-omnex.club"}`, http.StatusBadRequest},
|
||||
{"json invalide", path, `{`, http.StatusBadRequest},
|
||||
{"projet inconnu", "/projects/inconnu/domain", `{"domain":"a.client.fr"}`, http.StatusNotFound},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := do(r, "POST", c.path, c.body); got.Code != c.want {
|
||||
t.Errorf("%s : %d, attendu %d (%s)", c.name, got.Code, c.want, got.Body)
|
||||
}
|
||||
}
|
||||
|
||||
prov.domainErr = errors.New("helm: secret interne")
|
||||
if got := do(r, "POST", path, `{"domain":"boutique.client.fr"}`); got.Code != http.StatusInternalServerError || strings.Contains(got.Body.String(), "secret") {
|
||||
t.Errorf("erreur cluster : %d %s (500 sans détail interne attendu)", got.Code, got.Body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ type Project struct {
|
||||
Namespace string `gorm:"size:63;uniqueIndex" json:"namespace"`
|
||||
Host string `gorm:"size:255" json:"host"`
|
||||
URL string `gorm:"size:255" json:"url"`
|
||||
// CustomDomain : domaine du client, servi en plus de Host ("" = aucun).
|
||||
// URL pointe dessus quand il est défini.
|
||||
CustomDomain string `gorm:"size:255" json:"custom_domain,omitempty"`
|
||||
|
||||
// AdminUsername : compte admin créé dans le backend déployé (le mot de
|
||||
// passe n'est jamais persisté). AdminNumber : ADMIN_NUMBER du backend.
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -22,6 +23,9 @@ var (
|
||||
ErrInvalidAdmin = errors.New("identifiant admin invalide (3 à 64 caractères alphanumériques)")
|
||||
ErrWeakAdminPass = errors.New("mot de passe admin trop court (12 caractères minimum)")
|
||||
ErrInvalidAdminSize = errors.New("nombre d'admins invalide (1 à 20)")
|
||||
ErrNotReady = errors.New("le projet doit être en ligne pour changer de domaine")
|
||||
ErrDomainReserved = errors.New("ce domaine appartient à Omnex et ne peut pas être utilisé")
|
||||
ErrDomainTaken = errors.New("ce domaine est déjà utilisé par un autre projet")
|
||||
)
|
||||
|
||||
var adminUsernamePattern = regexp.MustCompile(`^[A-Za-z0-9]{3,64}$`)
|
||||
@@ -31,14 +35,16 @@ var adminUsernamePattern = regexp.MustCompile(`^[A-Za-z0-9]{3,64}$`)
|
||||
type Provisioner interface {
|
||||
ProvisionProject(spec demos.ProjectSpec) error
|
||||
TeardownProject(namespace string) error
|
||||
UpdateProjectDomain(spec demos.ProjectDomainSpec) error
|
||||
ProjectState(ctx context.Context, namespace string) (demos.ResourceState, error)
|
||||
}
|
||||
|
||||
// NoopProvisioner : aucun déploiement réel (dev en mémoire, tests).
|
||||
type NoopProvisioner struct{}
|
||||
|
||||
func (NoopProvisioner) ProvisionProject(demos.ProjectSpec) error { return nil }
|
||||
func (NoopProvisioner) TeardownProject(string) error { return nil }
|
||||
func (NoopProvisioner) ProvisionProject(demos.ProjectSpec) error { return nil }
|
||||
func (NoopProvisioner) TeardownProject(string) error { return nil }
|
||||
func (NoopProvisioner) UpdateProjectDomain(demos.ProjectDomainSpec) error { return nil }
|
||||
func (NoopProvisioner) ProjectState(context.Context, string) (demos.ResourceState, error) {
|
||||
return demos.ResourceState{}, nil
|
||||
}
|
||||
@@ -46,6 +52,10 @@ func (NoopProvisioner) ProjectState(context.Context, string) (demos.ResourceStat
|
||||
// Config du service (injectable pour les tests).
|
||||
type Config struct {
|
||||
Domain string // domaine des projets : <namespace>.<Domain>
|
||||
// ReservedDomains : domaines (et leurs sous-domaines) qu'un client ne peut
|
||||
// pas revendiquer comme domaine personnalisé — ceux d'Omnex (démos…). Le
|
||||
// domaine des projets (Domain) est toujours réservé.
|
||||
ReservedDomains []string
|
||||
}
|
||||
|
||||
// CreateInput : saisie de l'admin Omnex au déploiement (dashboard).
|
||||
@@ -226,6 +236,76 @@ func (s *Service) Extend(id string, months int) (Project, error) {
|
||||
return s.store.Update(p)
|
||||
}
|
||||
|
||||
// validateDomain vérifie un domaine personnalisé (déjà normalisé). Vide = valide
|
||||
// (retour au domaine par défaut). Refuse les adresses IP et tout domaine
|
||||
// d'Omnex : sans cela un projet pourrait capter le trafic d'un autre (son
|
||||
// adresse par défaut) ou des démos.
|
||||
func (s *Service) validateDomain(domain string) error {
|
||||
if domain == "" {
|
||||
return nil
|
||||
}
|
||||
if err := demos.ValidateDomain(domain); err != nil || net.ParseIP(domain) != nil {
|
||||
return demos.ErrInvalidDomain
|
||||
}
|
||||
for _, r := range append([]string{s.cfg.Domain}, s.cfg.ReservedDomains...) {
|
||||
r = strings.ToLower(strings.TrimSpace(r))
|
||||
if r != "" && (domain == r || strings.HasSuffix(domain, "."+r)) {
|
||||
return ErrDomainReserved
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetDomain définit (ou retire, si domain est vide) le domaine personnalisé du
|
||||
// client. Le site reste servi sur son adresse par défaut en plus du domaine :
|
||||
// le DNS du domaine doit pointer vers le cluster et un certificat qui le
|
||||
// couvre doit être déclaré dans le WAF (voir deploy/chart-vitrine/README.md).
|
||||
func (s *Service) SetDomain(id, domain string) (Project, error) {
|
||||
domain = strings.ToLower(strings.TrimSpace(domain))
|
||||
if err := s.validateDomain(domain); err != nil {
|
||||
return Project{}, err
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
p, ok := s.store.Get(id)
|
||||
if !ok {
|
||||
return Project{}, ErrNotFound
|
||||
}
|
||||
if p.Status != StatusReady {
|
||||
return Project{}, ErrNotReady
|
||||
}
|
||||
if domain != "" {
|
||||
all, err := s.store.List()
|
||||
if err != nil {
|
||||
return Project{}, err
|
||||
}
|
||||
for _, other := range all {
|
||||
live := other.Status == StatusPending || other.Status == StatusProvisioning || other.Status == StatusReady
|
||||
if live && other.ID != p.ID && other.CustomDomain == domain {
|
||||
return Project{}, ErrDomainTaken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
url := "https://" + p.Host
|
||||
if domain != "" {
|
||||
url = "https://" + domain
|
||||
}
|
||||
if err := s.prov.UpdateProjectDomain(demos.ProjectDomainSpec{
|
||||
Namespace: p.Namespace,
|
||||
Host: p.Host,
|
||||
CustomDomain: domain,
|
||||
URL: url,
|
||||
}); err != nil {
|
||||
return Project{}, err
|
||||
}
|
||||
p.CustomDomain = domain
|
||||
p.URL = url
|
||||
return s.store.Update(p)
|
||||
}
|
||||
|
||||
// Delete détruit le projet (namespace, données, sauvegardes) sans attendre
|
||||
// l'échéance — action explicite de l'admin.
|
||||
func (s *Service) Delete(id string) (Project, error) {
|
||||
|
||||
@@ -20,6 +20,8 @@ type fakeProv struct {
|
||||
state demos.ResourceState
|
||||
stateErr error
|
||||
stateCalls []string
|
||||
domainSpecs []demos.ProjectDomainSpec
|
||||
domainErr error
|
||||
provisioned chan struct{}
|
||||
}
|
||||
|
||||
@@ -46,12 +48,19 @@ func (f *fakeProv) ProjectState(_ context.Context, ns string) (demos.ResourceSta
|
||||
return f.state, f.stateErr
|
||||
}
|
||||
|
||||
func (f *fakeProv) UpdateProjectDomain(s demos.ProjectDomainSpec) error {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.domainSpecs = append(f.domainSpecs, s)
|
||||
return f.domainErr
|
||||
}
|
||||
|
||||
var t0 = time.Date(2026, time.September, 20, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
func newTestService(t *testing.T) (*Service, *fakeProv, *time.Time) {
|
||||
t.Helper()
|
||||
prov := newFakeProv()
|
||||
svc := NewService(NewMemStore(), prov, Config{Domain: "vitrine-omnex.club"})
|
||||
svc := NewService(NewMemStore(), prov, Config{Domain: "vitrine-omnex.club", ReservedDomains: []string{"omnex.sbs"}})
|
||||
now := t0
|
||||
svc.now = func() time.Time { return now }
|
||||
return svc, prov, &now
|
||||
@@ -333,3 +342,107 @@ func TestState_UnknownProjectAndClusterError(t *testing.T) {
|
||||
t.Error("erreur du cluster avalée")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomain_SetsServedDomainAndKeepsDefaultHost(t *testing.T) {
|
||||
svc, prov, _ := newTestService(t)
|
||||
p := createReady(t, svc, prov, validInput())
|
||||
|
||||
got, err := svc.SetDomain(p.ID, " Boutique.Client.FR ")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.CustomDomain != "boutique.client.fr" || got.URL != "https://boutique.client.fr" {
|
||||
t.Errorf("domaine=%q url=%q", got.CustomDomain, got.URL)
|
||||
}
|
||||
if got.Host != p.Host {
|
||||
t.Errorf("l'hôte par défaut a changé : %q", got.Host)
|
||||
}
|
||||
want := demos.ProjectDomainSpec{Namespace: p.Namespace, Host: p.Host, CustomDomain: "boutique.client.fr", URL: "https://boutique.client.fr"}
|
||||
if len(prov.domainSpecs) != 1 || prov.domainSpecs[0] != want {
|
||||
t.Errorf("spec envoyée au cluster : %+v", prov.domainSpecs)
|
||||
}
|
||||
stored, _ := svc.Get(p.ID)
|
||||
if stored.CustomDomain != "boutique.client.fr" {
|
||||
t.Errorf("non persisté : %+v", stored)
|
||||
}
|
||||
|
||||
// Domaine vide : retour à l'adresse par défaut.
|
||||
got, err = svc.SetDomain(p.ID, "")
|
||||
if err != nil || got.CustomDomain != "" || got.URL != p.URL {
|
||||
t.Errorf("retrait : err=%v domaine=%q url=%q (attendu %q)", err, got.CustomDomain, got.URL, p.URL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomain_RejectsInvalidAndReservedDomains(t *testing.T) {
|
||||
svc, prov, _ := newTestService(t)
|
||||
p := createReady(t, svc, prov, validInput())
|
||||
other := createReady(t, svc, prov, validInput())
|
||||
|
||||
invalid := []string{"pas un domaine", "http://x.fr", "x.fr/chemin", "localhost", "*.client.fr", "10.0.0.1", "-a.fr"}
|
||||
for _, d := range invalid {
|
||||
if _, err := svc.SetDomain(p.ID, d); !errors.Is(err, demos.ErrInvalidDomain) {
|
||||
t.Errorf("%q : erreur %v, attendu ErrInvalidDomain", d, err)
|
||||
}
|
||||
}
|
||||
reserved := []string{"vitrine-omnex.club", other.Host, "x.vitrine-omnex.club", "omnex.sbs", "demo-1.omnex.sbs"}
|
||||
for _, d := range reserved {
|
||||
if _, err := svc.SetDomain(p.ID, d); !errors.Is(err, ErrDomainReserved) {
|
||||
t.Errorf("%q : erreur %v, attendu ErrDomainReserved", d, err)
|
||||
}
|
||||
}
|
||||
// Un domaine qui finit par la même chaîne sans être un sous-domaine reste permis.
|
||||
if _, err := svc.SetDomain(p.ID, "monomnex.sbs"); err != nil {
|
||||
t.Errorf("monomnex.sbs refusé à tort : %v", err)
|
||||
}
|
||||
if len(prov.domainSpecs) != 1 {
|
||||
t.Errorf("le cluster ne doit être appelé que pour le domaine valide : %d appels", len(prov.domainSpecs))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomain_DomainAlreadyUsedByAnotherProject(t *testing.T) {
|
||||
svc, prov, _ := newTestService(t)
|
||||
a := createReady(t, svc, prov, validInput())
|
||||
b := createReady(t, svc, prov, validInput())
|
||||
|
||||
if _, err := svc.SetDomain(a.ID, "boutique.client.fr"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := svc.SetDomain(b.ID, "boutique.client.fr"); !errors.Is(err, ErrDomainTaken) {
|
||||
t.Errorf("erreur %v, attendu ErrDomainTaken", err)
|
||||
}
|
||||
// Le même projet peut le redéfinir (idempotent).
|
||||
if _, err := svc.SetDomain(a.ID, "boutique.client.fr"); err != nil {
|
||||
t.Errorf("redéfinition par le propriétaire : %v", err)
|
||||
}
|
||||
// Une fois le premier projet supprimé, le domaine est libre.
|
||||
if _, err := svc.Delete(a.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := svc.SetDomain(b.ID, "boutique.client.fr"); err != nil {
|
||||
t.Errorf("domaine d'un projet supprimé toujours bloqué : %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomain_StateAndClusterErrors(t *testing.T) {
|
||||
svc, prov, _ := newTestService(t)
|
||||
if _, err := svc.SetDomain("inconnu", "x.client.fr"); !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("erreur %v, attendu ErrNotFound", err)
|
||||
}
|
||||
|
||||
p := createReady(t, svc, prov, validInput())
|
||||
prov.domainErr = errors.New("helm indisponible")
|
||||
if _, err := svc.SetDomain(p.ID, "x.client.fr"); err == nil {
|
||||
t.Fatal("erreur du cluster avalée")
|
||||
}
|
||||
if got, _ := svc.Get(p.ID); got.CustomDomain != "" || got.URL != p.URL {
|
||||
t.Errorf("échec du cluster mais projet modifié : %+v", got)
|
||||
}
|
||||
|
||||
prov.domainErr = nil
|
||||
if _, err := svc.Delete(p.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := svc.SetDomain(p.ID, "x.client.fr"); !errors.Is(err, ErrNotReady) {
|
||||
t.Errorf("projet supprimé : erreur %v, attendu ErrNotReady", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ func New(d Deps) *gin.Engine {
|
||||
admin.GET("/projects/:id/details", d.ProjectsH.Details)
|
||||
admin.DELETE("/projects/:id", d.ProjectsH.Delete)
|
||||
admin.POST("/projects/:id/extend", d.ProjectsH.Extend)
|
||||
admin.POST("/projects/:id/domain", d.ProjectsH.SetDomain)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,36 @@ séparé, monté dans le control-plane sur `/charts-vitrine` (volume du `docker-
|
||||
de grâce : il faut donc renouveler avant l'échéance. Un `DELETE /projects/:id` fait la même chose
|
||||
immédiatement.
|
||||
|
||||
## Domaine personnalisé (à la demande du client)
|
||||
|
||||
Dashboard Projets → icône d'édition à côté de l'adresse, ou
|
||||
`POST /projects/:id/domain {"domain": "boutique.client.fr"}` (domaine vide = retrait).
|
||||
Le site reste servi sur son adresse par défaut **en plus** du domaine du client (`extraHosts` du
|
||||
chart `ingressroute`) : rien n'est coupé si le DNS ou le certificat ne sont pas encore prêts.
|
||||
Le control-plane refuse les adresses IP, les domaines d'Omnex (`vitrine-omnex.club`, domaine des
|
||||
démos) et un domaine déjà pris par un autre projet. Le backend reprend l'URL du domaine pour les
|
||||
liens de médias (`MEDIA_LOCAL_BASE_URL`), ce qui le redéploie brièvement.
|
||||
|
||||
Deux étapes **manuelles**, que le control-plane ne fait pas :
|
||||
|
||||
1. **DNS (côté client)** : enregistrement `A` du domaine vers les IP des nœuds du cluster.
|
||||
2. **Certificat** : le WAF termine le TLS et choisit son certificat par SNI, donc un domaine
|
||||
absent de `tls.extra` reçoit le certificat par défaut (erreur dans le navigateur). Les ClusterIssuers
|
||||
existants sont en DNS-01 Cloudflare pour nos propres zones : ils ne couvrent pas le domaine d'un client.
|
||||
Obtenir un certificat (certbot, ou autre CA) puis :
|
||||
```bash
|
||||
kubectl create secret tls tls-boutique-client-fr -n traefik --cert=fullchain.pem --key=privkey.pem
|
||||
```
|
||||
et le déclarer dans `deploy/chart-gestion/waf-cluster/values.yaml` :
|
||||
```yaml
|
||||
tls:
|
||||
extra:
|
||||
- serverName: "boutique.client.fr"
|
||||
secretName: tls-boutique-client-fr
|
||||
```
|
||||
puis `helm upgrade gestion-waf-cluster deploy/chart-gestion/waf-cluster -n traefik --reset-then-reuse-values`.
|
||||
Le certificat n'est pas renouvelé automatiquement avec cette méthode.
|
||||
|
||||
Sauvegardes : un `Schedule` Velero par namespace, créé au déploiement et supprimé avec le
|
||||
projet, identique à celui des démos (toutes les 15 min, conservé 24 h, File System Backup).
|
||||
|
||||
|
||||
@@ -5,6 +5,16 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Condition Traefik sur le nom d'hôte : l'hôte par défaut, plus les domaines
|
||||
personnalisés du client (extraHosts) — ex. Host(`a.vitrine-omnex.club`) || Host(`boutique.client.fr`).
|
||||
*/}}
|
||||
{{- define "ingressroute.hostRule" -}}
|
||||
{{- $hosts := list (printf "Host(`%s`)" .Values.host) -}}
|
||||
{{- range .Values.extraHosts }}{{ $hosts = append $hosts (printf "Host(`%s`)" .) }}{{ end -}}
|
||||
{{- join " || " $hosts -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "ingressroute.backendService" -}}
|
||||
{{- .Values.backend.serviceName | default (printf "%s-backend-vitrine-backend" .Release.Namespace) }}
|
||||
{{- end }}
|
||||
|
||||
@@ -18,7 +18,7 @@ spec:
|
||||
routes:
|
||||
# API backend — WAF + headers + rate limit (middlewares partagés, définis
|
||||
# dans le namespace du Traefik commun, référencés cross-namespace).
|
||||
- match: Host(`{{ .Values.host }}`) && (PathPrefix(`/api/`))
|
||||
- match: ({{ include "ingressroute.hostRule" . }}) && PathPrefix(`/api/`)
|
||||
kind: Rule
|
||||
priority: 20
|
||||
middlewares:
|
||||
@@ -29,7 +29,7 @@ spec:
|
||||
port: {{ .Values.backend.servicePort }}
|
||||
|
||||
# Fichiers uploadés — WAF désactivé dans les règles Coraza pour ce path
|
||||
- match: Host(`{{ .Values.host }}`) && PathPrefix(`/uploads/`)
|
||||
- match: ({{ include "ingressroute.hostRule" . }}) && PathPrefix(`/uploads/`)
|
||||
kind: Rule
|
||||
priority: 15
|
||||
middlewares:
|
||||
@@ -40,7 +40,7 @@ spec:
|
||||
port: {{ .Values.backend.servicePort }}
|
||||
|
||||
# Frontend SPA — WAF + headers + rate limit
|
||||
- match: Host(`{{ .Values.host }}`)
|
||||
- match: {{ include "ingressroute.hostRule" . }}
|
||||
kind: Rule
|
||||
priority: 1
|
||||
middlewares:
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
# (calculé par le control-plane : <namespace>.<domaine vitrine>).
|
||||
host: ""
|
||||
|
||||
# Domaines personnalisés du client (ex. boutique.client.fr), servis EN PLUS de
|
||||
# `host`. Gérés par le control-plane (POST /projects/:id/domain). Le DNS doit
|
||||
# pointer vers le cluster et un certificat couvrant le domaine doit être
|
||||
# déclaré dans le WAF (deploy/chart-gestion/waf-cluster, tls.extra).
|
||||
extraHosts: []
|
||||
|
||||
# Namespace où tourne le Traefik partagé et ses Middlewares (waf-chain,
|
||||
# rate-limit, coraza-waf, security-headers) — voir deploy/chart-gestion/traefik.
|
||||
traefikNamespace: traefik
|
||||
|
||||
+2
-2
@@ -3,7 +3,6 @@
|
||||
|
||||
# --- Secrets obligatoires ---
|
||||
OMNEX_JWT_SECRET=0879032aa29538641920360c1990e39f7e86123b1fa869e9e3e60d44ceca0a34
|
||||
OMNEX_SEED_PASSWORD=62dc702dfe26d117216d2994
|
||||
|
||||
# --- Postgres ---
|
||||
POSTGRES_USER=omnex
|
||||
@@ -15,7 +14,6 @@ REDIS_PASSWORD=630fa654c76f1256fea3ba3c51a718a4
|
||||
|
||||
# --- API ---
|
||||
OMNEX_ENV=dev
|
||||
OMNEX_SEED_USERNAME=admin
|
||||
OMNEX_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
|
||||
OMNEX_DEMO_DOMAIN=192.168.1.31.nip.io
|
||||
OMNEX_DEMO_HTTPS_PORT=31908
|
||||
@@ -23,3 +21,5 @@ KUBECONFIG=/home/xor_fakers/.kube/config
|
||||
FRONTEND_IMAGE_APP=xor1234/frontend-mln:helm
|
||||
BACKEND_IMAGE_APP=xor1234/backend-mln:helm
|
||||
LBTELEGRAM_IMAGE_APP=xor1234/lbtelegram:helm
|
||||
VITRINE_BACKEND_IMAGE=xor1234/vitrine-api:latest
|
||||
VITRINE_FRONTEND_IMAGE=xor1234/vitrine-web:latest
|
||||
|
||||
+10
-12
@@ -42,6 +42,11 @@ services:
|
||||
- ANOMALY_INBOUND=5
|
||||
- ANOMALY_OUTBOUND=4
|
||||
- MODSEC_AUDIT_LOG=/var/log/modsec/modsec_audit.log
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-sk", "-f", "https://localhost:443/healthz"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
volumes:
|
||||
- ./nginx/certs:/etc/nginx/certs:ro
|
||||
- /var/log/waf/nginx:/var/log/nginx
|
||||
@@ -68,29 +73,22 @@ services:
|
||||
OMNEX_ALLOWED_ORIGINS: ${OMNEX_ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:5173}
|
||||
OMNEX_DATABASE_URL: "host=postgres user=${POSTGRES_USER:-omnex} password=${POSTGRES_PASSWORD:-omnex} dbname=${POSTGRES_DB:-omnex} port=5432 sslmode=disable"
|
||||
OMNEX_REDIS_URL: "redis://:${REDIS_PASSWORD:-omnexredis}@redis:6379/0"
|
||||
OMNEX_SEED_USERNAME: ${OMNEX_SEED_USERNAME:-admin}
|
||||
OMNEX_SEED_PASSWORD: ${OMNEX_SEED_PASSWORD}
|
||||
OMNEX_DEMO_DOMAIN: ${OMNEX_DEMO_DOMAIN:-192.168.1.31.nip.io}
|
||||
OMNEX_DEMO_DOMAIN: ${OMNEX_DEMO_DOMAIN:-omnex.sbs}
|
||||
OMNEX_DEMO_HTTPS_PORT: ${OMNEX_DEMO_HTTPS_PORT:-443}
|
||||
FRONTEND_IMAGE_APP: ${FRONTEND_IMAGE_APP:-xor1234/frontend-mln:helm}
|
||||
BACKEND_IMAGE_APP: ${BACKEND_IMAGE_APP:-xor1234/backend-mln:helm}
|
||||
LBTELEGRAM_IMAGE_APP: ${LBTELEGRAM_IMAGE_APP:-xor1234/lbtelegram:helm}
|
||||
OMNEX_VITRINE_DOMAIN: ${OMNEX_VITRINE_DOMAIN:-vitrine-omnex.club}
|
||||
VITRINE_BACKEND_IMAGE: ${VITRINE_BACKEND_IMAGE:-xor1234/vitrine-api:latest}
|
||||
VITRINE_FRONTEND_IMAGE: ${VITRINE_FRONTEND_IMAGE:-xor1234/vitrine-web:latest}
|
||||
KUBECONFIG: /kubeconfig/config
|
||||
OMNEX_APP_DOWNLOADS_DIR: /app-downloads
|
||||
# Compte Docker Hub authentifié (lecture seule) injecté dans chaque
|
||||
# namespace de démo — passe le rate-limit de pull anonyme (100/6h par
|
||||
# IP) à 200/6h. Vide = pull anonyme (comportement inchangé).
|
||||
OMNEX_DOCKERHUB_USERNAME: ${OMNEX_DOCKERHUB_USERNAME:-}
|
||||
OMNEX_DOCKERHUB_PASSWORD: ${OMNEX_DOCKERHUB_PASSWORD:-}
|
||||
volumes:
|
||||
- ../deploy/chart-gestion:/charts:ro
|
||||
- ../deploy/chart-vitrine:/charts-vitrine:ro
|
||||
- ${KUBECONFIG_HOST_PATH:-/home/xor_fakers/.kube/config}:/kubeconfig/config:ro
|
||||
# Dossier où déposer manuellement les .apk (Admin Panel / Client) à
|
||||
# rendre téléchargeables aux clients ayant une démo ou un abonnement
|
||||
# actif — voir control-plane/api/internal/downloads. Vit dans
|
||||
# docker/ (comme waf/, nginx/, certs/) : sur le serveur, seuls
|
||||
# docker-compose.yml et waf/ sont synchronisés par Ansible, le
|
||||
# reste (dont app/) est géré manuellement dans docker_dir.
|
||||
- ./app:/app-downloads:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
# lignes de taille raisonnable.
|
||||
SecAuditLogParts ABIFHZ
|
||||
|
||||
# 911100 (REQUEST-911-METHOD-ENFORCEMENT) n'autorise par défaut que GET
|
||||
# HEAD POST OPTIONS — bloque tout DELETE/PUT/PATCH légitimes de l'API REST
|
||||
# (ex: DELETE /api/v1/demos/:id, toujours 403 "Method is not allowed by
|
||||
# policy" avant même d'atteindre le check de rôle admin). Même correctif déjà
|
||||
# appliqué côté Coraza/Traefik pour les démos, voir
|
||||
# deploy/chart-gestion/traefik/templates/middleware-waf.yaml.
|
||||
SecRuleRemoveById 911100
|
||||
|
||||
SecRule IP:BANNED "@eq 1" \
|
||||
"id:100000,phase:1,deny,status:403,log,\
|
||||
msg:'IP is banned'"
|
||||
|
||||
Vendored
+1510
File diff suppressed because one or more lines are too long
Vendored
-1510
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Omnex — Plateforme de gestion de commandes & livraison</title>
|
||||
<meta name="description" content="Déployez en un clic une démo complète de la plateforme de gestion de commandes et de livraison." />
|
||||
<script type="module" crossorigin src="/assets/index-rDhSK02l.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BdLZEtG3.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Center, Spinner } from '@chakra-ui/react'
|
||||
import { Landing } from './pages/Landing'
|
||||
import { Pricing } from './pages/Pricing'
|
||||
import { Documentation } from './pages/Documentation'
|
||||
import { Vitrine } from './pages/Vitrine'
|
||||
import { Login } from './pages/Login'
|
||||
import { AdminLogin } from './pages/AdminLogin'
|
||||
import { Register } from './pages/Register'
|
||||
@@ -64,6 +65,7 @@ export function App() {
|
||||
<Route path="/" element={<Landing />} />
|
||||
<Route path="/tarifs" element={<Pricing />} />
|
||||
<Route path="/documentation" element={<Documentation />} />
|
||||
<Route path="/vitrine" element={<Vitrine />} />
|
||||
<Route path="/contact" element={<Contact />} />
|
||||
</Route>
|
||||
<Route path="/login" element={<Login />} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import {
|
||||
Button,
|
||||
FormControl,
|
||||
@@ -16,15 +16,22 @@ import {
|
||||
} from '@chakra-ui/react'
|
||||
import { api, ApiError, type Demo } from '../lib/api'
|
||||
|
||||
// Ce dont le modal a besoin : une démo ou un projet vitrine conviennent.
|
||||
type DomainTarget = Pick<Demo, 'id' | 'namespace' | 'custom_domain'>
|
||||
|
||||
interface EditDomainModalProps {
|
||||
demo: Demo | null
|
||||
demo: DomainTarget | null
|
||||
onClose: () => void
|
||||
onSaved: () => void
|
||||
// Enregistrement du domaine (défaut : démo). Les projets vitrine passent le leur.
|
||||
save?: (id: string, domain: string) => Promise<unknown>
|
||||
title?: string
|
||||
helpText?: ReactNode
|
||||
}
|
||||
|
||||
// Modal d'édition du domaine public d'une démo — partagé entre le dashboard
|
||||
// Demos et le dashboard Premium.
|
||||
export function EditDomainModal({ demo, onClose, onSaved }: EditDomainModalProps) {
|
||||
// Modal d'édition du domaine public d'une démo ou d'un projet vitrine —
|
||||
// partagé entre les dashboards Demos, Premium et Projets.
|
||||
export function EditDomainModal({ demo, onClose, onSaved, save, title, helpText }: EditDomainModalProps) {
|
||||
const toast = useToast()
|
||||
const [domain, setDomain] = useState('')
|
||||
const [saving, setSaving] = useState(false)
|
||||
@@ -42,7 +49,7 @@ export function EditDomainModal({ demo, onClose, onSaved }: EditDomainModalProps
|
||||
if (!demo) return
|
||||
setSaving(true)
|
||||
try {
|
||||
await api.setDemoDomain(demo.id, domain.trim())
|
||||
await (save ?? api.setDemoDomain)(demo.id, domain.trim())
|
||||
toast({ status: 'success', title: 'Domaine mis à jour' })
|
||||
onSaved()
|
||||
onClose()
|
||||
@@ -58,7 +65,7 @@ export function EditDomainModal({ demo, onClose, onSaved }: EditDomainModalProps
|
||||
<Modal isOpen={!!demo} onClose={handleClose} closeOnOverlayClick={!saving}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader>Domaine de la plateforme</ModalHeader>
|
||||
<ModalHeader>{title ?? 'Domaine de la plateforme'}</ModalHeader>
|
||||
<ModalCloseButton isDisabled={saving} />
|
||||
<ModalBody>
|
||||
<FormControl>
|
||||
@@ -71,10 +78,14 @@ export function EditDomainModal({ demo, onClose, onSaved }: EditDomainModalProps
|
||||
fontFamily="mono"
|
||||
/>
|
||||
<FormHelperText>
|
||||
Laissez vide pour revenir au domaine par défaut ({demo?.namespace}.<domaine
|
||||
omnex>). Le DNS du domaine choisi doit pointer vers le cluster, et un certificat
|
||||
TLS valide doit le couvrir — le certificat wildcard partagé ne couvre que le domaine
|
||||
par défaut.
|
||||
{helpText ?? (
|
||||
<>
|
||||
Laissez vide pour revenir au domaine par défaut ({demo?.namespace}.<domaine
|
||||
omnex>). Le DNS du domaine choisi doit pointer vers le cluster, et un certificat
|
||||
TLS valide doit le couvrir — le certificat wildcard partagé ne couvre que le
|
||||
domaine par défaut.
|
||||
</>
|
||||
)}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
|
||||
@@ -20,6 +20,7 @@ export function Footer() {
|
||||
<FooterLink to="/tarifs">Tarifs</FooterLink>
|
||||
<FooterLink to="/register">Créer un compte</FooterLink>
|
||||
<FooterLink to="/documentation">Documentation</FooterLink>
|
||||
<FooterLink to="/vitrine">Site vitrine</FooterLink>
|
||||
</FooterCol>
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ const navLinks = [
|
||||
{ to: '/', label: 'Accueil', end: true },
|
||||
{ to: '/tarifs', label: 'Tarifs', end: false },
|
||||
{ to: '/documentation', label: 'Documentation', end: false },
|
||||
{ to: '/vitrine', label: 'Site vitrine', end: false },
|
||||
{ to: '/contact', label: 'Contact', end: false },
|
||||
]
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ export interface Project {
|
||||
namespace: string
|
||||
host: string
|
||||
url: string
|
||||
// Domaine du client, servi en plus de l'adresse par défaut (host).
|
||||
custom_domain?: string
|
||||
admin_username: string
|
||||
admin_number: number
|
||||
months_purchased: number
|
||||
@@ -258,6 +260,8 @@ export const api = {
|
||||
admin_password: params.adminPassword,
|
||||
admin_number: params.adminNumber,
|
||||
}),
|
||||
setProjectDomain: (id: string, domain: string) =>
|
||||
request<Project>('POST', `/projects/${id}/domain`, { domain }),
|
||||
extendProject: (id: string, months: number) =>
|
||||
request<Project>('POST', `/projects/${id}/extend`, { months }),
|
||||
deleteProject: (id: string) => request<Project>('DELETE', `/projects/${id}`),
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Contact commercial : toute demande de devis passe par Telegram.
|
||||
export const SUPPORT_TELEGRAM_URL = 'https://t.me/OMNEX_CORP'
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
Text,
|
||||
} from '@chakra-ui/react'
|
||||
import { Link as RouterLink } from 'react-router-dom'
|
||||
import { SUPPORT_TELEGRAM_URL } from '../lib/links'
|
||||
|
||||
const SUPPORT_TELEGRAM_URL = 'https://t.me/OMNEX_CORP'
|
||||
|
||||
interface Plan {
|
||||
name: string
|
||||
@@ -62,6 +62,20 @@ const plans: Plan[] = [
|
||||
ctaExternal: true,
|
||||
highlighted: true,
|
||||
},
|
||||
{
|
||||
name: 'Site vitrine',
|
||||
price: 'Sur devis',
|
||||
period: '',
|
||||
description: 'Une boutique en ligne hébergée par nos soins, avec son espace d\'administration.',
|
||||
features: [
|
||||
'Catalogue, panier et commandes',
|
||||
'Durée de 1 à 12 mois, payée en une fois',
|
||||
'Environnement dédié, sauvegardé et protégé',
|
||||
],
|
||||
cta: 'Nous contacter',
|
||||
ctaHref: SUPPORT_TELEGRAM_URL,
|
||||
ctaExternal: true,
|
||||
},
|
||||
]
|
||||
|
||||
export function Pricing() {
|
||||
@@ -70,11 +84,11 @@ export function Pricing() {
|
||||
<Stack spacing={4} textAlign="center" mb={12} align="center">
|
||||
<Heading size="2xl">Tarifs</Heading>
|
||||
<Text fontSize="lg" color="gray.600" maxW="2xl">
|
||||
Commencez par une démo gratuite de 30 jours, puis passez en premium quand vous êtes prêt.
|
||||
Commencez par une démo gratuite de 30 jours, puis passez en premium quand vous êtes prêt. Les sites vitrines se commandent sur devis.
|
||||
</Text>
|
||||
</Stack>
|
||||
|
||||
<SimpleGrid columns={{ base: 1, md: 2 }} spacing={8} alignItems="stretch" maxW="2xl" mx="auto">
|
||||
<SimpleGrid columns={{ base: 1, md: 3 }} spacing={8} alignItems="stretch" mx="auto">
|
||||
{plans.map((plan) => (
|
||||
<PlanCard key={plan.name} plan={plan} />
|
||||
))}
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Container,
|
||||
Heading,
|
||||
HStack,
|
||||
List,
|
||||
ListIcon,
|
||||
ListItem,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
} from '@chakra-ui/react'
|
||||
import { SUPPORT_TELEGRAM_URL } from '../lib/links'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
interface Block {
|
||||
kicker: string
|
||||
title: string
|
||||
lead: string
|
||||
points: string[]
|
||||
}
|
||||
|
||||
// Ce que le client final voit : la boutique en ligne.
|
||||
const STOREFRONT: Block[] = [
|
||||
{
|
||||
kicker: 'Catalogue',
|
||||
title: 'Vos produits, classés par catégories',
|
||||
lead: 'Photos et vidéos par produit, catégories ordonnées à votre convenance, et plusieurs tarifs par produit selon la quantité et l\'unité de vente.',
|
||||
points: [
|
||||
'Paliers de prix par unité (g, kg, pièce…)',
|
||||
'Catégories avec image, ordre d\'affichage libre',
|
||||
'Fiche produit avec galerie média',
|
||||
],
|
||||
},
|
||||
{
|
||||
kicker: 'Commande',
|
||||
title: 'Un panier et une commande en quelques clics',
|
||||
lead: 'Le visiteur compose son panier et valide sa commande. Vous la recevez dans votre espace admin et suivez son avancement jusqu\'à la fin.',
|
||||
points: [
|
||||
'Statuts : en attente, confirmée, en préparation, expédiée, terminée, annulée',
|
||||
'Historique des commandes pour les clients connectés',
|
||||
'Ouverture et fermeture des commandes d\'un simple interrupteur',
|
||||
],
|
||||
},
|
||||
{
|
||||
kicker: 'Comptes clients',
|
||||
title: 'Des comptes clients, activables à la demande',
|
||||
lead: 'Laissez commander sans compte, ou exigez-en un. Vous pouvez aussi demander une vérification d\'identité avant d\'autoriser l\'accès.',
|
||||
points: [
|
||||
'Création de compte activable ou non',
|
||||
'Vérification par pièce d\'identité (recto / verso), validée ou refusée par vos soins',
|
||||
'Pièces stockées dans un volume dédié, séparé des médias publics',
|
||||
],
|
||||
},
|
||||
{
|
||||
kicker: 'Contact',
|
||||
title: 'Vos réseaux et messageries, sur une page dédiée',
|
||||
lead: 'Ajoutez les liens de votre choix (Telegram, WhatsApp, réseaux sociaux…) avec leur icône et leur couleur, et choisissez ceux qui sont visibles.',
|
||||
points: ['Liens ordonnés et activables un par un', 'Icône et couleur par lien', 'Style des cartes (transparent ou plein) réglable'],
|
||||
},
|
||||
]
|
||||
|
||||
// Ce que l'administrateur du site peut régler lui-même.
|
||||
const BACKOFFICE: Block[] = [
|
||||
{
|
||||
kicker: 'Apparence',
|
||||
title: 'Un site à vos couleurs',
|
||||
lead: 'Couleurs de l\'en-tête, du fond, du texte, du pied de page et de l\'accent, avec le logo et l\'image d\'accueil de votre choix.',
|
||||
points: [
|
||||
'Produits en grille ou en liste, nombre de colonnes réglable',
|
||||
'Défilement vertical ou horizontal',
|
||||
'Thème clair ou sombre pour vos visiteurs',
|
||||
],
|
||||
},
|
||||
{
|
||||
kicker: 'Langues',
|
||||
title: 'Quatre langues pour vos visiteurs',
|
||||
lead: 'Le site s\'affiche en français, anglais, espagnol ou allemand, au choix du visiteur.',
|
||||
points: ['Sélecteur de langue intégré', 'Choix mémorisé pour les visites suivantes'],
|
||||
},
|
||||
{
|
||||
kicker: 'Notifications',
|
||||
title: 'Chaque nouvelle commande sur Telegram',
|
||||
lead: 'Reliez un bot Telegram : vous êtes prévenu dès qu\'une commande arrive, et, si vous le souhaitez, à chaque changement de statut.',
|
||||
points: ['Alerte de nouvelle commande', 'Alerte de changement de statut, en option'],
|
||||
},
|
||||
{
|
||||
kicker: 'Équipe',
|
||||
title: 'Un espace admin, avec le nombre de comptes que vous choisissez',
|
||||
lead: 'Le nombre de comptes administrateurs est fixé à la commande du site, de 1 à 20, pour partager la gestion avec votre équipe.',
|
||||
points: ['Tableau de bord, commandes, produits, catégories, unités', 'Gestion des comptes clients et des vérifications'],
|
||||
},
|
||||
]
|
||||
|
||||
const HOSTING: { title: string; text: string }[] = [
|
||||
{
|
||||
title: 'Environnement dédié',
|
||||
text: 'Chaque site tourne dans son propre espace isolé, avec sa base de données et son cache. Rien n\'est partagé avec les autres clients.',
|
||||
},
|
||||
{
|
||||
title: 'HTTPS et pare-feu applicatif',
|
||||
text: 'Le site est servi en HTTPS, derrière un pare-feu applicatif (WAF) qui filtre les requêtes malveillantes.',
|
||||
},
|
||||
{
|
||||
title: 'Sauvegardes automatiques',
|
||||
text: 'Les données (base et médias) sont sauvegardées automatiquement et stockées sur des volumes répliqués.',
|
||||
},
|
||||
{
|
||||
title: 'Votre propre nom de domaine',
|
||||
text: 'Le site est livré sur une adresse Omnex. Si vous le souhaitez, il peut aussi répondre sur votre domaine (par exemple boutique.votre-marque.fr) : demandez-le-nous au moment de la commande.',
|
||||
},
|
||||
{
|
||||
title: 'Mis en ligne sans attente',
|
||||
text: 'Une fois votre commande validée, le site est déployé en quelques minutes et accessible sur son adresse dédiée.',
|
||||
},
|
||||
]
|
||||
|
||||
function FeatureBlock({ block }: { block: Block }) {
|
||||
return (
|
||||
<Box p={6} borderWidth="1px" borderRadius="xl" bg="bg-surface">
|
||||
<Text fontSize="xs" fontWeight="extrabold" letterSpacing="wide" textTransform="uppercase" color="primary.500" mb={2}>
|
||||
{block.kicker}
|
||||
</Text>
|
||||
<Heading size="md" mb={3}>
|
||||
{block.title}
|
||||
</Heading>
|
||||
<Text color="gray.500" mb={4} fontSize="sm">
|
||||
{block.lead}
|
||||
</Text>
|
||||
<List spacing={2}>
|
||||
{block.points.map((p) => (
|
||||
<ListItem key={p} fontSize="sm" color="gray.600" display="flex">
|
||||
<ListIcon as={() => <FontAwesomeIcon icon={faCheck} />} color="green.400" mt={1} mr={2} />
|
||||
<span>{p}</span>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
// Présentation du site vitrine vendu sur abonnement (voir deploy/chart-vitrine).
|
||||
export function Vitrine() {
|
||||
return (
|
||||
<Box>
|
||||
{/* Hero */}
|
||||
<Box bgGradient="linear(to-b, blackAlpha.50, transparent)" py={{ base: 14, md: 20 }}>
|
||||
<Container maxW="container.lg">
|
||||
<Stack spacing={5} textAlign="center" align="center">
|
||||
<HStack spacing={2}>
|
||||
<Badge colorScheme="primary" px={3} py={1} borderRadius="full">
|
||||
Site vitrine
|
||||
</Badge>
|
||||
<Badge variant="outline" px={3} py={1} borderRadius="full">
|
||||
Abonnement de 1 à 12 mois
|
||||
</Badge>
|
||||
</HStack>
|
||||
<Heading size="2xl">Votre boutique en ligne, prête à l'emploi</Heading>
|
||||
<Text fontSize="lg" color="gray.500" maxW="2xl">
|
||||
Un site complet pour présenter vos produits et recevoir des commandes, avec son espace d'administration.
|
||||
Nous le déployons, l'hébergeons et le sauvegardons pour vous, pour la durée de votre abonnement.
|
||||
</Text>
|
||||
<Button as="a" href={SUPPORT_TELEGRAM_URL} target="_blank" rel="noopener noreferrer" colorScheme="primary" size="lg" mt={2}>
|
||||
Nous contacter
|
||||
</Button>
|
||||
</Stack>
|
||||
</Container>
|
||||
</Box>
|
||||
|
||||
{/* Côté visiteur */}
|
||||
<Container maxW="container.lg" py={{ base: 10, md: 14 }}>
|
||||
<Stack spacing={2} mb={8} textAlign="center">
|
||||
<Heading size="lg">Ce que vos clients voient</Heading>
|
||||
<Text color="gray.500">La boutique : catalogue, panier, commande, compte et contact.</Text>
|
||||
</Stack>
|
||||
<SimpleGrid columns={{ base: 1, md: 2 }} spacing={5}>
|
||||
{STOREFRONT.map((b) => (
|
||||
<FeatureBlock key={b.kicker} block={b} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</Container>
|
||||
|
||||
{/* Côté admin */}
|
||||
<Box bg="chakra-subtle-bg" borderTopWidth="1px" borderBottomWidth="1px">
|
||||
<Container maxW="container.lg" py={{ base: 10, md: 14 }}>
|
||||
<Stack spacing={2} mb={8} textAlign="center">
|
||||
<Heading size="lg">Ce que vous réglez vous-même</Heading>
|
||||
<Text color="gray.500">Un espace d'administration pour faire vivre le site sans nous solliciter.</Text>
|
||||
</Stack>
|
||||
<SimpleGrid columns={{ base: 1, md: 2 }} spacing={5}>
|
||||
{BACKOFFICE.map((b) => (
|
||||
<FeatureBlock key={b.kicker} block={b} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</Container>
|
||||
</Box>
|
||||
|
||||
{/* Hébergement */}
|
||||
<Container maxW="container.lg" py={{ base: 10, md: 14 }}>
|
||||
<Stack spacing={2} mb={8} textAlign="center">
|
||||
<Heading size="lg">Hébergé et surveillé par Omnex</Heading>
|
||||
<Text color="gray.500">Vous n'installez rien : nous nous occupons de l'infrastructure.</Text>
|
||||
</Stack>
|
||||
<SimpleGrid columns={{ base: 1, sm: 2 }} spacing={5}>
|
||||
{HOSTING.map((h) => (
|
||||
<Box key={h.title} p={5} borderWidth="1px" borderRadius="lg">
|
||||
<Heading size="sm" mb={2}>
|
||||
{h.title}
|
||||
</Heading>
|
||||
<Text fontSize="sm" color="gray.500">
|
||||
{h.text}
|
||||
</Text>
|
||||
</Box>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</Container>
|
||||
|
||||
{/* Abonnement */}
|
||||
<Box borderTopWidth="1px" py={{ base: 10, md: 14 }}>
|
||||
<Container maxW="container.md">
|
||||
<Stack spacing={4} textAlign="center" align="center">
|
||||
<Heading size="lg">Un abonnement que vous choisissez</Heading>
|
||||
<Text color="gray.500">
|
||||
Vous commandez une durée de 1 à 12 mois. Elle se renouvelle à tout moment, en ajoutant des mois à votre
|
||||
échéance. Sans renouvellement avant l'échéance, le site et ses données sont supprimés : pensez à
|
||||
prolonger à temps.
|
||||
</Text>
|
||||
</Stack>
|
||||
</Container>
|
||||
</Box>
|
||||
|
||||
{/* CTA */}
|
||||
<Box bg="gray.900" color="white" py={20} textAlign="center">
|
||||
<Container maxW="container.md">
|
||||
<Heading size="xl" mb={4}>
|
||||
Un site vitrine pour votre activité ?
|
||||
</Heading>
|
||||
<Text color="whiteAlpha.700" mb={8}>
|
||||
Parlez-nous de votre projet sur Telegram : nous vous répondons avec une offre adaptée.
|
||||
</Text>
|
||||
<Button as="a" href={SUPPORT_TELEGRAM_URL} target="_blank" rel="noopener noreferrer" colorScheme="primary" size="lg">
|
||||
Nous contacter
|
||||
</Button>
|
||||
</Container>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Heading,
|
||||
HStack,
|
||||
Icon,
|
||||
IconButton,
|
||||
Link,
|
||||
Spacer,
|
||||
Spinner,
|
||||
@@ -22,11 +23,13 @@ import {
|
||||
useToast,
|
||||
Wrap,
|
||||
} from '@chakra-ui/react'
|
||||
import { EditIcon } from '@chakra-ui/icons'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { api, ApiError, type DemoDetails, type Project } from '../../lib/api'
|
||||
import { formatDate, monthsLabel, projectStatusColor, projectStatusLabel, timeRemaining } from '../../lib/format'
|
||||
import { ConfirmDialog } from '../../components/ConfirmDialog'
|
||||
import { CreateProjectModal } from '../../components/CreateProjectModal'
|
||||
import { EditDomainModal } from '../../components/EditDomainModal'
|
||||
import { ExtendProjectModal } from '../../components/ExtendProjectModal'
|
||||
import { ChevronIcon, PodStatusPanel } from '../../components/PodStatusPanel'
|
||||
|
||||
@@ -46,6 +49,7 @@ export function Projects() {
|
||||
const [createOpen, setCreateOpen] = useState(false)
|
||||
const [toExtend, setToExtend] = useState<Project | null>(null)
|
||||
const [toDelete, setToDelete] = useState<Project | null>(null)
|
||||
const [editingDomain, setEditingDomain] = useState<Project | null>(null)
|
||||
|
||||
// --- Ligne dépliée (état live des pods) ---
|
||||
const [expandedId, setExpandedId] = useState<string | null>(null)
|
||||
@@ -201,15 +205,28 @@ export function Projects() {
|
||||
<Badge colorScheme={projectStatusColor(p.status)}>{projectStatusLabel(p.status)}</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
<Link
|
||||
href={p.url}
|
||||
isExternal
|
||||
fontFamily="mono"
|
||||
fontSize="sm"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{p.host}
|
||||
</Link>
|
||||
<HStack spacing={1}>
|
||||
<Link
|
||||
href={p.url}
|
||||
isExternal
|
||||
fontFamily="mono"
|
||||
fontSize="sm"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{p.custom_domain || p.host}
|
||||
</Link>
|
||||
<IconButton
|
||||
aria-label="Modifier le domaine"
|
||||
icon={<EditIcon />}
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
isDisabled={p.status !== 'ready'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setEditingDomain(p)
|
||||
}}
|
||||
/>
|
||||
</HStack>
|
||||
</Td>
|
||||
<Td>{monthsLabel(p.months_purchased)} au total</Td>
|
||||
<Td>{deadline(p)}</Td>
|
||||
@@ -272,6 +289,22 @@ export function Projects() {
|
||||
)}
|
||||
|
||||
<CreateProjectModal isOpen={createOpen} onClose={() => setCreateOpen(false)} onCreated={() => void load()} />
|
||||
<EditDomainModal
|
||||
demo={editingDomain}
|
||||
onClose={() => setEditingDomain(null)}
|
||||
onSaved={() => void load()}
|
||||
save={api.setProjectDomain}
|
||||
title="Domaine du site"
|
||||
helpText={
|
||||
<>
|
||||
Domaine du client (ex. boutique.client.fr), servi en plus de l'adresse par défaut
|
||||
{editingDomain ? ` (${editingDomain.host})` : ''}, qui reste active. Laissez vide pour retirer le
|
||||
domaine. Avant de l'enregistrer : le DNS du domaine doit pointer vers les nœuds du cluster, et
|
||||
son certificat TLS doit être ajouté au WAF (voir deploy/chart-vitrine/README.md), sans quoi le
|
||||
navigateur affichera une erreur de certificat.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<ExtendProjectModal project={toExtend} onClose={() => setToExtend(null)} onExtended={() => void load()} />
|
||||
<ConfirmDialog
|
||||
isOpen={!!toDelete}
|
||||
|
||||
Reference in New Issue
Block a user