Thomas Fransolet b87e49d808 Cle d'API sur les routes visiteur, canal VR et contenu immersif
Securite
- RequireAppKey : filtre qui exige une cle d'API valide ou un utilisateur du
  manager. Pose sur les routes de contenu consommees par les apps visiteur
  (Configuration, Section, Resource, SectionMap, SectionEvent, SectionAgenda,
  SectionParcours, SectionQuiz, ApplicationInstance). Un [Authorize] d'action
  ne peut pas assouplir celui de la classe ; seul [AllowAnonymous] le
  court-circuite, et le filtre redevient le controle d'acces. Il ferme
  l'enumeration par identifiant, pas la confidentialite : la cle s'obtient
  par le slug ou le pincode.
- Instance/slug/{slug} rendait le pinCode, l'adresse de facturation, la TVA et
  les quotas a qui lit l'URL du site visiteur. StripCommercialFields est
  desormais applique sur slug et byPin ; isTrialActive reste expose pour le
  filigrane d'essai.
- Device.Create et Device/{id}/detail repondaient 403 a toute tablette depuis
  a452f4a (13/03) : la classe exige InstanceAdmin, une cle ne porte que
  AppRead. Ouverts a la cle, le cloisonnement par instance etait deja ecrit.

Canal VR
- Device.AppType (defaut Tablet, backfill a 1) ; Create resout
  l'ApplicationInstance sur ce type au lieu de Tablet en dur.
- Get filtre optionnellement par appType ; DeviceDetailDTO expose appVersion
  et lastSeen.
- PUT Device/{id}/heartbeat : batterie, version, connexion. Volontairement
  etroit, une app ne peut ni se renommer ni changer d'instance.
- ApiKeyAppType.VrApp en fin d'enum.

Contenu immersif
- ResourceType : Image360 (11), Video360 (12), Model3D (13), en fin d'enum.
- Section Scene3D : un modele GLB et ses points d'interet, en objet manipule
  ou en decor habite. Les points sont des GeoPoint, avec une LocalTransform
  en jsonb (convention glTF) ; CRUD dans SectionScene3DController.
- Instance.HasImmersiveContent : l'add-on ajoute 100 Go au quota de stockage,
  repose apres un changement de plan et retire a la desactivation.
- ImmersiveBackground (owned) sur Configuration et ApplicationInstance, avec
  une image de repli pour les canaux qui ne rendent pas l'immersif.

Export de configuration
- exportVersion (1) et generatedAt : le JSON devient un contrat, lu tel quel
  par l'app Unity.
- Section.ToDTO() n'etant pas virtuelle, l'export ne portait aucun champ
  specifique de sous-type. Passe par SectionFactory.ToDTO, et charge les
  points des Map et des Scene3D.
- Le fond immersif et son repli partent avec les ressources, URL resolues.

Migrations : AddAppTypeToDevice, AddScene3DSectionAndImmersiveAddon,
AddImmersiveBackground.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 16:54:10 +02:00

112 lines
3.8 KiB
C#

using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using Microsoft.EntityFrameworkCore;
namespace ManagerService.Data
{
/// <summary>
/// Configuration Information
/// </summary>
[Index(nameof(InstanceId))]
public class Configuration : IAuditableEntity
{
[Key]
[Required]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
public string Label { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
public string ImageId { get; set; }
public string ImageSource { get; set; }
public string PrimaryColor { get; set; } // Config can have their specific colors
public string SecondaryColor { get; set; } // Config can have their specific colors
public List<string> Languages { get; set; } // Config can support not all the languages (help to translate step by step)
public DateTime DateCreation { get; set; }
public DateTime DateUpdate { get; set; }
public bool IsOffline { get; set; }
public string LoaderImageId { get; set; } // Config can have their specific loader if needed
public string LoaderImageUrl { get; set; } // Config can have their specific loader if needed
public bool IsQRCode { get; set; }
public bool IsSearchText { get; set; } // True if we want to have search box (text type), false otherwise
public bool IsSearchNumber { get; set; } // True if we want to have search box (number type), false otherwise
/// <summary>
/// Le fond de cette visite, null si elle n'en a pas. Voir
/// <see cref="Data.ImmersiveBackground"/> — le même type sert au menu VR.
/// </summary>
public ImmersiveBackground ImmersiveBackground { get; set; }
public ConfigurationDTO ToDTO(List<string> sectionIds)
{
return new ConfigurationDTO()
{
id = Id,
instanceId = InstanceId,
label = Label,
title = Title,
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isOffline = IsOffline,
immersiveBackground = ImmersiveBackground?.ToDTO(),
sectionIds = sectionIds
};
}
public ExportConfigurationDTO ToExportDTO(List<SectionDTO> sections, List<ResourceDTO> resources) {
return new ExportConfigurationDTO()
{
exportVersion = ExportConfigurationDTO.CurrentExportVersion,
generatedAt = DateTime.UtcNow,
id = Id,
instanceId = InstanceId,
label = Label,
title = Title,
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isOffline = IsOffline,
immersiveBackground = ImmersiveBackground?.ToDTO(),
sections = sections,
resources = resources,
sectionIds = sections.Select(s => s.id).ToList()
};
}
}
}