suppression de la partie patreon
This commit is contained in:
@@ -47,7 +47,7 @@ jobs:
|
|||||||
|
|
||||||
# Detection du canal :
|
# Detection du canal :
|
||||||
# - tag vX.Y.Z -> stable (push :latest + :version sur les repos publics)
|
# - tag vX.Y.Z -> stable (push :latest + :version sur les repos publics)
|
||||||
# - tag vX.Y.Z-beta* -> beta (push :beta + :version sur les repos GHCR prives
|
# - tag vX.Y.Z-beta* -> beta (push :beta + :version sur les repos GHCR publics
|
||||||
# loremind-beta-<component> ; backup Gitea avec :version)
|
# loremind-beta-<component> ; backup Gitea avec :version)
|
||||||
- name: Extract version & channel
|
- name: Extract version & channel
|
||||||
id: meta
|
id: meta
|
||||||
@@ -74,8 +74,8 @@ jobs:
|
|||||||
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_NAMESPACE }}/loremind-${{ matrix.component }}:${{ steps.meta.outputs.version }}
|
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_NAMESPACE }}/loremind-${{ matrix.component }}:${{ steps.meta.outputs.version }}
|
||||||
|
|
||||||
# Build & push canal BETA
|
# Build & push canal BETA
|
||||||
# GHCR : repos prives loremind-beta-<component> (gated par PAT distribue
|
# GHCR : repos PUBLICS loremind-beta-<component> (canal beta libre ;
|
||||||
# via le relais Patreon aux tiers Compagnon).
|
# le switcher bascule IMAGE_NAMESPACE vers ce prefixe).
|
||||||
# Gitea : backup prive avec :version uniquement (pas de :latest pour ne
|
# Gitea : backup prive avec :version uniquement (pas de :latest pour ne
|
||||||
# pas faire upgrader les installs branchees sur Gitea).
|
# pas faire upgrader les installs branchees sur Gitea).
|
||||||
- name: Build & push ${{ matrix.component }} (beta)
|
- name: Build & push ${{ matrix.component }} (beta)
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ name: Desktop installers
|
|||||||
# inclus) pour que le tag declenche ce workflow.
|
# inclus) pour que le tag declenche ce workflow.
|
||||||
#
|
#
|
||||||
# Tag stable vX.Y.Z -> GitHub Release PUBLIQUE avec le .msi attache.
|
# Tag stable vX.Y.Z -> GitHub Release PUBLIQUE avec le .msi attache.
|
||||||
# Tag beta vX.Y.Z-beta* -> AUCUNE publication publique. Le .msi est depose en
|
# Tag beta vX.Y.Z-beta* -> GitHub Release PUBLIQUE marquee « pre-release » : le
|
||||||
# ARTEFACT PRIVE du run (telechargeable seulement par
|
# canal beta est libre. /releases/latest l'ignore, donc
|
||||||
# toi via l'onglet Actions) ; tu le joins ensuite a un
|
# seules les installations beta en sont prevenues
|
||||||
# post Patreon reserve a un palier. Patreon = la
|
# (cf. DesktopUpdateService).
|
||||||
# barriere d'acces (equivalent du registry prive +
|
|
||||||
# relais pour les images Docker beta).
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -169,33 +167,23 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: .\installers\desktop\build-windows.ps1 -Version ${{ steps.ver.outputs.version }}
|
run: .\installers\desktop\build-windows.ps1 -Version ${{ steps.ver.outputs.version }}
|
||||||
|
|
||||||
# STABLE uniquement : Release GitHub publique avec le .msi.
|
# Release GitHub publique avec le .msi ; une beta est publiee en pre-release.
|
||||||
# tag_name explicite : en declenchement manuel, github.ref est une branche,
|
# tag_name explicite : en declenchement manuel, github.ref est une branche,
|
||||||
# donc on cible le tag derive (la release est attachee au bon tag).
|
# donc on cible le tag derive (la release est attachee au bon tag).
|
||||||
- name: Publish installer to GitHub Release (stable)
|
- name: Publish installer to GitHub Release
|
||||||
if: ${{ steps.ver.outputs.isbeta == 'false' }}
|
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.ver.outputs.tag }}
|
tag_name: ${{ steps.ver.outputs.tag }}
|
||||||
files: core/target/dist-out/*.msi
|
files: core/target/dist-out/*.msi
|
||||||
fail_on_unmatched_files: true
|
fail_on_unmatched_files: true
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
prerelease: ${{ steps.ver.outputs.isbeta == 'true' }}
|
||||||
# BETA uniquement : artefact PRIVE (pas de release publique). A recuperer
|
|
||||||
# via l'onglet Actions puis a joindre a un post Patreon gate par palier.
|
|
||||||
- name: Upload installer as private artifact (beta)
|
|
||||||
if: ${{ steps.ver.outputs.isbeta == 'true' }}
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: loremind-beta-${{ steps.ver.outputs.version }}-msi
|
|
||||||
path: core/target/dist-out/*.msi
|
|
||||||
retention-days: 90
|
|
||||||
|
|
||||||
# LINUX : AppImage (1 fichier, toutes distros) attache a la MEME release.
|
# LINUX : AppImage (1 fichier, toutes distros) attache a la MEME release.
|
||||||
# Tourne sur ubuntu-latest (jpackage ne cross-compile pas -> build natif Linux).
|
# Tourne sur ubuntu-latest (jpackage ne cross-compile pas -> build natif Linux).
|
||||||
# Brain empaquete via python-build-standalone (pas de Python embeddable Linux
|
# Brain empaquete via python-build-standalone (pas de Python embeddable Linux
|
||||||
# officiel ; pas de PyInstaller -> pas de faux positif AV). Memes regles de
|
# officiel ; pas de PyInstaller -> pas de faux positif AV). Memes regles de
|
||||||
# publication que windows : stable -> release publique ; beta -> artefact prive.
|
# publication que windows : stable -> release publique ; beta -> pre-release.
|
||||||
linux:
|
linux:
|
||||||
needs: tests
|
needs: tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -242,21 +230,13 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
run: bash ./installers/desktop/build-linux.sh --version ${{ steps.ver.outputs.version }}
|
run: bash ./installers/desktop/build-linux.sh --version ${{ steps.ver.outputs.version }}
|
||||||
|
|
||||||
# STABLE uniquement : attache l'AppImage a la release publique (meme tag que
|
# Attache l'AppImage a la release (meme tag que le .msi -> les deux
|
||||||
# le .msi -> les deux installeurs sur la meme release).
|
# installeurs sur la meme release). prerelease aussi ici : le job qui cree
|
||||||
- name: Publish AppImage to GitHub Release (stable)
|
# la release en premier fixe son statut.
|
||||||
if: ${{ steps.ver.outputs.isbeta == 'false' }}
|
- name: Publish AppImage to GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.ver.outputs.tag }}
|
tag_name: ${{ steps.ver.outputs.tag }}
|
||||||
files: core/target/dist-out/DM_Loremind*.AppImage
|
files: core/target/dist-out/DM_Loremind*.AppImage
|
||||||
fail_on_unmatched_files: true
|
fail_on_unmatched_files: true
|
||||||
|
prerelease: ${{ steps.ver.outputs.isbeta == 'true' }}
|
||||||
# BETA uniquement : artefact PRIVE (pas de release publique).
|
|
||||||
- name: Upload AppImage as private artifact (beta)
|
|
||||||
if: ${{ steps.ver.outputs.isbeta == 'true' }}
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: loremind-beta-${{ steps.ver.outputs.version }}-appimage
|
|
||||||
path: core/target/dist-out/DM_Loremind*.AppImage
|
|
||||||
retention-days: 90
|
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
brain/data/settings.json
|
brain/data/settings.json
|
||||||
*.key
|
*.key
|
||||||
*.pem
|
*.pem
|
||||||
# Exception : la cle PUBLIQUE JWT du relais Patreon est destinee a etre
|
|
||||||
# embarquee dans le binaire. Pas de risque a la committer (c'est une cle
|
|
||||||
# publique par construction). Sans cette exception, le module licensing
|
|
||||||
# est silencieusement desactive dans les builds CI.
|
|
||||||
!core/src/main/resources/licensing/jwt-public-key.pem
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Java / Spring Boot / Maven
|
# Java / Spring Boot / Maven
|
||||||
|
|||||||
+1
-2
@@ -7,7 +7,6 @@
|
|||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://loremind-docs.igmlcreation.fr/)
|
[](https://loremind-docs.igmlcreation.fr/)
|
||||||
[](https://loremind-demo.igmlcreation.fr/)
|
[](https://loremind-demo.igmlcreation.fr/)
|
||||||
[](https://www.patreon.com/c/IGMLCreation)
|
|
||||||
[](https://discord.gg/cPpFzCjEzQ)
|
[](https://discord.gg/cPpFzCjEzQ)
|
||||||
|
|
||||||
## Découvrir DM Loremind en vidéo
|
## Découvrir DM Loremind en vidéo
|
||||||
@@ -67,7 +66,7 @@ Quelques limites à connaître :
|
|||||||
|
|
||||||
DM Loremind est **et restera gratuit en auto-hébergement**. Le développement avance plus vite avec votre soutien :
|
DM Loremind est **et restera gratuit en auto-hébergement**. Le développement avance plus vite avec votre soutien :
|
||||||
|
|
||||||
- **[Patreon](https://www.patreon.com/c/IGMLCreation)** — accès anticipé aux features, vote sur la roadmap, devlogs exclusifs
|
- **Canal bêta** — les nouveautés en avant-première, gratuites pour tous : bascule depuis les Paramètres (Docker) ou pré-version GitHub (bureau)
|
||||||
- **[Discord](https://discord.gg/cPpFzCjEzQ)** — annonces, support, retours utilisateurs
|
- **[Discord](https://discord.gg/cPpFzCjEzQ)** — annonces, support, retours utilisateurs
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://loremind-docs.igmlcreation.fr/en/)
|
[](https://loremind-docs.igmlcreation.fr/en/)
|
||||||
[](https://loremind-demo.igmlcreation.fr/)
|
[](https://loremind-demo.igmlcreation.fr/)
|
||||||
[](https://www.patreon.com/c/IGMLCreation)
|
|
||||||
[](https://discord.gg/cPpFzCjEzQ)
|
[](https://discord.gg/cPpFzCjEzQ)
|
||||||
|
|
||||||
## See DM Loremind in action
|
## See DM Loremind in action
|
||||||
@@ -67,7 +66,7 @@ A few limitations to be aware of:
|
|||||||
|
|
||||||
DM Loremind is **and will remain free when self-hosted**. Development moves faster with your support:
|
DM Loremind is **and will remain free when self-hosted**. Development moves faster with your support:
|
||||||
|
|
||||||
- **[Patreon](https://www.patreon.com/c/IGMLCreation)** — early access to features, roadmap voting, exclusive devlogs
|
- **Beta channel** — new features ahead of time, free for everyone: switch from Settings (Docker) or install a GitHub pre-release (desktop)
|
||||||
- **[Discord](https://discord.gg/cPpFzCjEzQ)** — announcements, support, user feedback
|
- **[Discord](https://discord.gg/cPpFzCjEzQ)** — announcements, support, user feedback
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -137,31 +137,6 @@
|
|||||||
<version>5.1.0</version>
|
<version>5.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Nimbus JOSE+JWT — verification des JWT Ed25519 (EdDSA) emis par le relais
|
|
||||||
Patreon. Supporte nativement les cles Ed25519 via BouncyCastle.
|
|
||||||
>= 10.0.2 : corrige CVE-2025-53864 (DoS par JSON profondement imbrique
|
|
||||||
dans le claim set — surface critique : JWT colle par l'utilisateur). -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.nimbusds</groupId>
|
|
||||||
<artifactId>nimbus-jose-jwt</artifactId>
|
|
||||||
<version>10.9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk18on</artifactId>
|
|
||||||
<version>1.84</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Google Tink : runtime requis par com.nimbusds.jose.crypto.Ed25519Verifier
|
|
||||||
(depuis Nimbus 9.x, la verification EdDSA delegue a Tink.subtle.Ed25519Verify).
|
|
||||||
Tink n'est PAS une dependance transitive de nimbus-jose-jwt → il faut
|
|
||||||
l'ajouter explicitement, sinon NoClassDefFoundError au premier verify().
|
|
||||||
>= 1.15 : embarque un protobuf-java corrige (CVE-2024-7254). -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.crypto.tink</groupId>
|
|
||||||
<artifactId>tink</artifactId>
|
|
||||||
<version>1.21.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- openhtmltopdf — rendu XHTML+CSS -> PDF, 100 % JVM (pas de binaire natif :
|
<!-- openhtmltopdf — rendu XHTML+CSS -> PDF, 100 % JVM (pas de binaire natif :
|
||||||
compatible distribution bureau locale via jpackage). Sert l'export PDF
|
compatible distribution bureau locale via jpackage). Sert l'export PDF
|
||||||
d'une campagne (livret). -->
|
d'une campagne (livret). -->
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.loremind.application.licensing;
|
package com.loremind.application.channel;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
package com.loremind.application.licensing;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.License;
|
|
||||||
import com.loremind.domain.licensing.LicenseClaims;
|
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
|
||||||
import com.loremind.domain.licensing.LicenseStatus;
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
import com.loremind.domain.licensing.ports.JwtVerifier;
|
|
||||||
import com.loremind.domain.licensing.ports.LicenseRelay;
|
|
||||||
import com.loremind.domain.licensing.ports.LicenseRepository;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service application pour la gestion de la licence Patreon.
|
|
||||||
* <p>
|
|
||||||
* Responsabilites :
|
|
||||||
* <ul>
|
|
||||||
* <li>Installer un nouveau JWT recu du relais (apres OAuth utilisateur)</li>
|
|
||||||
* <li>Calculer le {@link LicenseStatus} courant en respectant la grace period</li>
|
|
||||||
* <li>Renouveler le JWT avant expiration en appelant le relais</li>
|
|
||||||
* <li>Activer/desactiver le toggle "canal beta" cote utilisateur</li>
|
|
||||||
* <li>Distribuer les credentials registry pour le pull beta</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class LicenseService {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LicenseService.class);
|
|
||||||
|
|
||||||
private final LicenseRepository repository;
|
|
||||||
private final JwtVerifier jwtVerifier;
|
|
||||||
private final LicenseRelay relay;
|
|
||||||
private final long gracePeriodSeconds;
|
|
||||||
private final long refreshBeforeExpirySeconds;
|
|
||||||
private final boolean licensingEnabled;
|
|
||||||
|
|
||||||
public LicenseService(
|
|
||||||
LicenseRepository repository,
|
|
||||||
JwtVerifier jwtVerifier,
|
|
||||||
LicenseRelay relay,
|
|
||||||
@Value("${licensing.grace-period-days:14}") int gracePeriodDays,
|
|
||||||
@Value("${licensing.refresh-before-expiry-days:2}") int refreshBeforeExpiryDays,
|
|
||||||
@Value("${licensing.enabled:true}") boolean licensingEnabled) {
|
|
||||||
this.repository = repository;
|
|
||||||
this.jwtVerifier = jwtVerifier;
|
|
||||||
this.relay = relay;
|
|
||||||
this.gracePeriodSeconds = gracePeriodDays * 86_400L;
|
|
||||||
this.refreshBeforeExpirySeconds = refreshBeforeExpiryDays * 86_400L;
|
|
||||||
this.licensingEnabled = licensingEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true si le licensing Patreon est actif : il faut a la fois que la
|
|
||||||
* feature soit activee ({@code licensing.enabled}, faux en mode
|
|
||||||
* bureau/local ou le gating par image Docker n'a aucun sens) ET que
|
|
||||||
* le verifier soit configure (cle publique presente). Faux => l'UI
|
|
||||||
* masque toute la section Patreon, le daemon de refresh est no-op,
|
|
||||||
* et le canal beta est desactive.
|
|
||||||
*/
|
|
||||||
public boolean isLicensingEnabled() {
|
|
||||||
return licensingEnabled && jwtVerifier.isConfigured();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Genere ou retourne l'instance_id stable de cette installation.
|
|
||||||
* Stocke dans la licence elle-meme. Si pas de licence, en cree un volatil
|
|
||||||
* (sera persiste a la prochaine connexion).
|
|
||||||
*/
|
|
||||||
public String getOrCreateInstanceId() {
|
|
||||||
return repository.findCurrent()
|
|
||||||
.map(License::getInstanceId)
|
|
||||||
.orElseGet(() -> "li-" + UUID.randomUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construit l'URL OAuth pour ouvrir dans le navigateur de l'utilisateur.
|
|
||||||
*/
|
|
||||||
public String buildConnectUrl() {
|
|
||||||
return relay.buildConnectUrl(getOrCreateInstanceId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Installe un JWT recu du relais (l'utilisateur l'a colle dans l'UI ou
|
|
||||||
* recu via deep-link). Verifie la signature, extrait les claims, persiste.
|
|
||||||
*/
|
|
||||||
public LicenseSnapshot installToken(String rawJwt) throws InstallException {
|
|
||||||
if (!jwtVerifier.isConfigured()) {
|
|
||||||
throw new InstallException("Licensing feature not enabled (no public key configured)");
|
|
||||||
}
|
|
||||||
LicenseClaims claims;
|
|
||||||
try {
|
|
||||||
claims = jwtVerifier.verify(rawJwt);
|
|
||||||
} catch (JwtVerifier.JwtVerificationException e) {
|
|
||||||
throw new InstallException("Invalid JWT: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
Instant now = Instant.now();
|
|
||||||
if (claims.expiresAt().isBefore(now)) {
|
|
||||||
throw new InstallException("JWT already expired");
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<License> existing = repository.findCurrent();
|
|
||||||
License toSave = License.builder()
|
|
||||||
.id("current")
|
|
||||||
.rawJwt(rawJwt)
|
|
||||||
.patreonUserId(claims.subject())
|
|
||||||
.tierId(claims.tierId())
|
|
||||||
.instanceId(claims.instanceId())
|
|
||||||
.issuedAt(claims.issuedAt())
|
|
||||||
.expiresAt(claims.expiresAt())
|
|
||||||
.lastRefreshAttemptAt(now)
|
|
||||||
.lastRefreshSucceeded(true)
|
|
||||||
// Au premier install, on active le canal beta par defaut.
|
|
||||||
// Sur reinstall apres deconnexion, on respecte la valeur precedente.
|
|
||||||
.betaChannelEnabled(existing.map(License::isBetaChannelEnabled).orElse(true))
|
|
||||||
.createdAt(existing.map(License::getCreatedAt).orElse(now))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
License saved = repository.save(toSave);
|
|
||||||
log.info("Patreon license installed for user={} tier={} expires={}",
|
|
||||||
saved.getPatreonUserId(), saved.getTierId(), saved.getExpiresAt());
|
|
||||||
return snapshotOf(saved, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Etat courant de la licence pour exposition UI / decision technique.
|
|
||||||
*/
|
|
||||||
public LicenseSnapshot getCurrentSnapshot() {
|
|
||||||
return repository.findCurrent()
|
|
||||||
.map(l -> snapshotOf(l, Instant.now()))
|
|
||||||
.orElseGet(LicenseSnapshot::none);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Supprime la licence (deconnexion volontaire de Patreon par l'utilisateur).
|
|
||||||
*/
|
|
||||||
public void disconnect() {
|
|
||||||
repository.deleteCurrent();
|
|
||||||
log.info("Patreon license removed (user disconnect)");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Active ou desactive le canal beta. Necessite une licence valide ou en grace.
|
|
||||||
*/
|
|
||||||
public LicenseSnapshot setBetaChannelEnabled(boolean enabled) {
|
|
||||||
License current = repository.findCurrent()
|
|
||||||
.orElseThrow(() -> new IllegalStateException("No license installed"));
|
|
||||||
current.setBetaChannelEnabled(enabled);
|
|
||||||
License saved = repository.save(current);
|
|
||||||
return snapshotOf(saved, Instant.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tente un refresh si la licence est proche de l'expiration. Idempotent.
|
|
||||||
* Appele par le daemon planifie + manuellement via l'UI ("Reessayer").
|
|
||||||
*/
|
|
||||||
public void refreshIfNeeded() {
|
|
||||||
Optional<License> opt = repository.findCurrent();
|
|
||||||
if (opt.isEmpty()) return;
|
|
||||||
License current = opt.get();
|
|
||||||
Instant now = Instant.now();
|
|
||||||
long secondsUntilExpiry = Duration.between(now, current.getExpiresAt()).getSeconds();
|
|
||||||
if (secondsUntilExpiry > refreshBeforeExpirySeconds) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
doRefresh(current, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force un refresh immediat (bouton UI "Reessayer maintenant").
|
|
||||||
*/
|
|
||||||
public void forceRefresh() {
|
|
||||||
repository.findCurrent().ifPresent(license -> doRefresh(license, Instant.now()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tente le refresh aupres du relais et persiste le resultat (succes ou echec) sur
|
|
||||||
* la licence. Le succes/echec est lu depuis {@code lastRefreshSucceeded}, pas
|
|
||||||
* depuis un retour de methode : le tentative est deja actee cote persistance.
|
|
||||||
*/
|
|
||||||
private void doRefresh(License current, Instant now) {
|
|
||||||
log.info("Refreshing Patreon license (current expires {})", current.getExpiresAt());
|
|
||||||
try {
|
|
||||||
String newJwt = relay.refreshToken(current.getRawJwt());
|
|
||||||
LicenseClaims claims = jwtVerifier.verify(newJwt);
|
|
||||||
|
|
||||||
current.setRawJwt(newJwt);
|
|
||||||
current.setIssuedAt(claims.issuedAt());
|
|
||||||
current.setExpiresAt(claims.expiresAt());
|
|
||||||
current.setTierId(claims.tierId());
|
|
||||||
current.setLastRefreshAttemptAt(now);
|
|
||||||
current.setLastRefreshSucceeded(true);
|
|
||||||
repository.save(current);
|
|
||||||
log.info("License refreshed successfully (new expiry {})", claims.expiresAt());
|
|
||||||
} catch (LicenseRelay.RelayException e) {
|
|
||||||
current.setLastRefreshAttemptAt(now);
|
|
||||||
current.setLastRefreshSucceeded(false);
|
|
||||||
repository.save(current);
|
|
||||||
if (e.getKind() == LicenseRelay.RelayErrorKind.REJECTED) {
|
|
||||||
log.warn("Relay rejected refresh ({}): tier may have been cancelled", e.getMessage());
|
|
||||||
} else {
|
|
||||||
log.warn("Relay refresh transient failure ({}): {}", e.getKind(), e.getMessage());
|
|
||||||
}
|
|
||||||
} catch (JwtVerifier.JwtVerificationException e) {
|
|
||||||
current.setLastRefreshAttemptAt(now);
|
|
||||||
current.setLastRefreshSucceeded(false);
|
|
||||||
repository.save(current);
|
|
||||||
log.error("Relay returned a JWT that fails verification: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recupere les credentials registry pour pull du canal beta.
|
|
||||||
* @return empty si pas de licence valide ou relais en echec
|
|
||||||
*/
|
|
||||||
public Optional<RegistryCredentials> fetchRegistryCredentials() {
|
|
||||||
LicenseSnapshot snap = getCurrentSnapshot();
|
|
||||||
if (snap.status() != LicenseStatus.VALID && snap.status() != LicenseStatus.GRACE) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
License current = repository.findCurrent().orElse(null);
|
|
||||||
if (current == null) return Optional.empty();
|
|
||||||
try {
|
|
||||||
return Optional.of(relay.fetchRegistryCredentials(current.getRawJwt()));
|
|
||||||
} catch (LicenseRelay.RelayException e) {
|
|
||||||
log.warn("Cannot fetch registry credentials ({}): {}", e.getKind(), e.getMessage());
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private LicenseSnapshot snapshotOf(License l, Instant now) {
|
|
||||||
LicenseStatus status = computeStatus(l, now);
|
|
||||||
return new LicenseSnapshot(
|
|
||||||
status,
|
|
||||||
l.getPatreonUserId(),
|
|
||||||
l.getTierId(),
|
|
||||||
l.getInstanceId(),
|
|
||||||
l.getExpiresAt(),
|
|
||||||
l.getLastRefreshAttemptAt(),
|
|
||||||
l.isLastRefreshSucceeded(),
|
|
||||||
l.isBetaChannelEnabled()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LicenseStatus computeStatus(License l, Instant now) {
|
|
||||||
if (l.getExpiresAt() == null) return LicenseStatus.NONE;
|
|
||||||
if (now.isBefore(l.getExpiresAt())) return LicenseStatus.VALID;
|
|
||||||
long secondsPastExpiry = Duration.between(l.getExpiresAt(), now).getSeconds();
|
|
||||||
if (secondsPastExpiry <= gracePeriodSeconds) return LicenseStatus.GRACE;
|
|
||||||
return LicenseStatus.EXPIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class InstallException extends Exception {
|
|
||||||
public InstallException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.loremind.domain.licensing;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Licence Patreon installee dans cette instance LoreMind.
|
|
||||||
* <p>
|
|
||||||
* Singleton (une seule licence par instance, identifiee logiquement par
|
|
||||||
* {@code id = "current"}). Contient le JWT brut emis par le relais OAuth
|
|
||||||
* + les claims extraits a la verification, plus l'etat operationnel
|
|
||||||
* (derniere tentative de refresh, succes/echec).
|
|
||||||
* <p>
|
|
||||||
* <b>Note securite :</b> {@link #rawJwt} est stocke tel quel ; sa signature
|
|
||||||
* Ed25519 est verifiee a chaque lecture. Pas besoin de chiffrement au repos
|
|
||||||
* supplementaire — un attaquant qui a acces a la base a deja l'instance,
|
|
||||||
* et le JWT ne donne aucun pouvoir au-dela du canal beta de cette instance.
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
public class License {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
private String rawJwt;
|
|
||||||
|
|
||||||
private String patreonUserId;
|
|
||||||
|
|
||||||
private String tierId;
|
|
||||||
|
|
||||||
private String instanceId;
|
|
||||||
|
|
||||||
private Instant issuedAt;
|
|
||||||
|
|
||||||
private Instant expiresAt;
|
|
||||||
|
|
||||||
private Instant lastRefreshAttemptAt;
|
|
||||||
|
|
||||||
private boolean lastRefreshSucceeded;
|
|
||||||
|
|
||||||
private boolean betaChannelEnabled;
|
|
||||||
|
|
||||||
private Instant createdAt;
|
|
||||||
|
|
||||||
private Instant updatedAt;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.loremind.domain.licensing;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Claims extraits d'un JWT licence apres verification de signature.
|
|
||||||
* Immuable.
|
|
||||||
*/
|
|
||||||
public record LicenseClaims(
|
|
||||||
String subject,
|
|
||||||
String tierId,
|
|
||||||
String instanceId,
|
|
||||||
Instant issuedAt,
|
|
||||||
Instant expiresAt
|
|
||||||
) {}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.loremind.domain.licensing;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vue immuable de la licence pour exposition vers les couches superieures.
|
|
||||||
* Decouple le domaine du DTO web et permet de calculer le {@link LicenseStatus}
|
|
||||||
* a un instant donne sans muter l'entite.
|
|
||||||
*/
|
|
||||||
public record LicenseSnapshot(
|
|
||||||
LicenseStatus status,
|
|
||||||
String patreonUserId,
|
|
||||||
String tierId,
|
|
||||||
String instanceId,
|
|
||||||
Instant expiresAt,
|
|
||||||
Instant lastRefreshAttemptAt,
|
|
||||||
boolean lastRefreshSucceeded,
|
|
||||||
boolean betaChannelEnabled
|
|
||||||
) {
|
|
||||||
public static LicenseSnapshot none() {
|
|
||||||
return new LicenseSnapshot(LicenseStatus.NONE, null, null, null, null, null, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.loremind.domain.licensing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Etat operationnel de la licence vis-a-vis de l'acces beta.
|
|
||||||
* <p>
|
|
||||||
* Calcule a partir de la presence de licence + son JWT exp + grace period.
|
|
||||||
* <ul>
|
|
||||||
* <li>{@link #NONE} : aucune licence installee</li>
|
|
||||||
* <li>{@link #VALID} : JWT non expire, acces beta autorise</li>
|
|
||||||
* <li>{@link #GRACE} : JWT expire mais dans la periode de tolerance ;
|
|
||||||
* acces beta toujours autorise, l'UI doit avertir</li>
|
|
||||||
* <li>{@link #EXPIRED} : au-dela de la grace period, acces beta refuse</li>
|
|
||||||
* <li>{@link #UNVERIFIABLE} : JWT impossible a verifier (cle publique manquante,
|
|
||||||
* signature invalide, claims malformes) — traite comme NONE pour la securite</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public enum LicenseStatus {
|
|
||||||
NONE,
|
|
||||||
VALID,
|
|
||||||
GRACE,
|
|
||||||
EXPIRED,
|
|
||||||
UNVERIFIABLE
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.loremind.domain.licensing;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Credentials de pull pour un registry Docker, distribues par le relais
|
|
||||||
* apres verification d'un JWT licence valide.
|
|
||||||
* <p>
|
|
||||||
* {@code expiresAt} peut etre {@code null} si le credential est statique
|
|
||||||
* (cas du PAT GHCR partage en MVP) ; sinon, l'instance doit re-demander
|
|
||||||
* de nouveaux credentials avant cette date.
|
|
||||||
*/
|
|
||||||
public record RegistryCredentials(
|
|
||||||
String registry,
|
|
||||||
String username,
|
|
||||||
String password,
|
|
||||||
Instant expiresAt
|
|
||||||
) {}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.loremind.domain.licensing.ports;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Port de sortie : ecriture du docker config.json partage avec Watchtower.
|
|
||||||
* <p>
|
|
||||||
* Le fichier sert a Watchtower pour s'authentifier au registry prive (GHCR)
|
|
||||||
* lors du pull des images du canal beta. Volume Docker {@code docker-config}
|
|
||||||
* monte sur Core (en ecriture) et sur Watchtower (en lecture, via la variable
|
|
||||||
* {@code DOCKER_CONFIG}).
|
|
||||||
*/
|
|
||||||
public interface DockerConfigWriter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ecrit ou met a jour les credentials pour le registry indique.
|
|
||||||
* Cree le fichier s'il n'existe pas, conserve les autres registries deja
|
|
||||||
* presents (en theorie : aucun, mais defensif).
|
|
||||||
*/
|
|
||||||
void writeCredentials(RegistryCredentials credentials) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Supprime le fichier de credentials. Appele quand la licence est invalidee
|
|
||||||
* ou que le toggle beta passe a OFF.
|
|
||||||
*/
|
|
||||||
void clear() throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true si le fichier de creds existe actuellement.
|
|
||||||
*/
|
|
||||||
boolean isPresent();
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.loremind.domain.licensing.ports;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.LicenseClaims;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Port de sortie : verification de signature et extraction des claims
|
|
||||||
* d'un JWT emis par le relais.
|
|
||||||
* <p>
|
|
||||||
* Implemente cote infrastructure avec la cle publique Ed25519 embarquee
|
|
||||||
* (SPKI PEM via configuration {@code licensing.jwt.public-key}).
|
|
||||||
*/
|
|
||||||
public interface JwtVerifier {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifie la signature, l'issuer, l'audience et l'expiration du JWT.
|
|
||||||
* @throws JwtVerificationException si la signature est invalide ou les claims malformes
|
|
||||||
*/
|
|
||||||
LicenseClaims verify(String rawJwt) throws JwtVerificationException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true si la cle publique est configuree et utilisable.
|
|
||||||
* Permet a l'application de masquer la feature licensing si pas configuree.
|
|
||||||
*/
|
|
||||||
boolean isConfigured();
|
|
||||||
|
|
||||||
class JwtVerificationException extends Exception {
|
|
||||||
public JwtVerificationException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
public JwtVerificationException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package com.loremind.domain.licensing.ports;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Port de sortie vers le service relais OAuth Patreon.
|
|
||||||
* Encapsule les appels HTTP : refresh JWT et fetch registry credentials.
|
|
||||||
*/
|
|
||||||
public interface LicenseRelay {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Demande au relais l'URL OAuth a ouvrir pour connecter le compte Patreon.
|
|
||||||
*/
|
|
||||||
String buildConnectUrl(String instanceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Demande au relais de renouveler un JWT existant. Le relais re-verifie
|
|
||||||
* le tier Patreon de l'utilisateur ; renvoie un nouveau JWT si toujours
|
|
||||||
* actif, ou leve {@link RelayException} sinon.
|
|
||||||
*/
|
|
||||||
String refreshToken(String currentJwt) throws RelayException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Demande au relais les credentials de pull du registry beta.
|
|
||||||
*/
|
|
||||||
RegistryCredentials fetchRegistryCredentials(String currentJwt) throws RelayException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erreurs distinctes emises par le relais. Permet au service application
|
|
||||||
* de differencier "tier expire" (action utilisateur) de "relais down"
|
|
||||||
* (action transitoire, garde la grace period).
|
|
||||||
*/
|
|
||||||
class RelayException extends Exception {
|
|
||||||
private final RelayErrorKind kind;
|
|
||||||
|
|
||||||
public RelayException(RelayErrorKind kind, String message) {
|
|
||||||
super(message);
|
|
||||||
this.kind = kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RelayException(RelayErrorKind kind, String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
this.kind = kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RelayErrorKind getKind() {
|
|
||||||
return kind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum RelayErrorKind {
|
|
||||||
/** Le relais est joignable mais refuse : tier non actif, JWT trop ancien, etc. */
|
|
||||||
REJECTED,
|
|
||||||
/** Le relais a renvoye un JWT mais il est invalide / non parsable. */
|
|
||||||
BAD_RESPONSE,
|
|
||||||
/** Le relais est injoignable / 5xx / timeout. */
|
|
||||||
TRANSIENT
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.loremind.domain.licensing.ports;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.License;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Port de sortie pour la persistance de la licence installee.
|
|
||||||
* <p>
|
|
||||||
* Une seule licence par instance ({@code id = "current"} par convention).
|
|
||||||
*/
|
|
||||||
public interface LicenseRepository {
|
|
||||||
|
|
||||||
Optional<License> findCurrent();
|
|
||||||
|
|
||||||
License save(License license);
|
|
||||||
|
|
||||||
void deleteCurrent();
|
|
||||||
}
|
|
||||||
@@ -31,6 +31,9 @@ import java.util.Optional;
|
|||||||
* <p>
|
* <p>
|
||||||
* {@code /releases/latest} ne renvoie que les releases stables (pas les
|
* {@code /releases/latest} ne renvoie que les releases stables (pas les
|
||||||
* prereleases) : les utilisateurs stables ne sont donc pas notifies des betas.
|
* prereleases) : les utilisateurs stables ne sont donc pas notifies des betas.
|
||||||
|
* Une version BETA (le canal beta est libre : chaque beta est publiee en
|
||||||
|
* prerelease GitHub) interroge la liste complete des releases, pour etre
|
||||||
|
* prevenue de la beta suivante comme de la version stable qui la remplace.
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Profile("local")
|
@Profile("local")
|
||||||
@@ -73,17 +76,18 @@ public class DesktopUpdateService {
|
|||||||
headers.set(HttpHeaders.USER_AGENT, "LoreMind-Desktop");
|
headers.set(HttpHeaders.USER_AGENT, "LoreMind-Desktop");
|
||||||
headers.set(HttpHeaders.ACCEPT, "application/vnd.github+json");
|
headers.set(HttpHeaders.ACCEPT, "application/vnd.github+json");
|
||||||
|
|
||||||
|
boolean beta = isPrerelease(currentVersion);
|
||||||
ResponseEntity<JsonNode> resp = http.exchange(
|
ResponseEntity<JsonNode> resp = http.exchange(
|
||||||
releasesApiUrl, HttpMethod.GET, new HttpEntity<>(headers), JsonNode.class);
|
beta ? allReleasesUrl(releasesApiUrl) : releasesApiUrl,
|
||||||
JsonNode body = resp.getBody();
|
HttpMethod.GET, new HttpEntity<>(headers), JsonNode.class);
|
||||||
if (body == null || body.path("tag_name").isMissingNode()) {
|
JsonNode release = beta ? newestRelease(resp.getBody()) : resp.getBody();
|
||||||
|
if (release == null || release.path("tag_name").isMissingNode()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String tag = body.path("tag_name").asText(""); // ex: "v0.15.0"
|
String latest = version(release); // ex: "0.15.0"
|
||||||
String releaseUrl = body.path("html_url").asText(null); // page de la release
|
String releaseUrl = release.path("html_url").asText(null); // page de la release
|
||||||
String latest = tag.startsWith("v") ? tag.substring(1) : tag;
|
|
||||||
|
|
||||||
if (!latest.isBlank() && compareSemver(currentVersion, latest) < 0) {
|
if (!latest.isBlank() && (beta ? compareVersions(currentVersion, latest) : compareSemver(currentVersion, latest)) < 0) {
|
||||||
log.info("[Update] Nouvelle version disponible : {} (courante : {})", latest, currentVersion);
|
log.info("[Update] Nouvelle version disponible : {} (courante : {})", latest, currentVersion);
|
||||||
return Optional.of(new UpdateInfo(currentVersion, latest, releaseUrl));
|
return Optional.of(new UpdateInfo(currentVersion, latest, releaseUrl));
|
||||||
}
|
}
|
||||||
@@ -99,6 +103,66 @@ public class DesktopUpdateService {
|
|||||||
/** Infos d'une mise a jour disponible. */
|
/** Infos d'une mise a jour disponible. */
|
||||||
public record UpdateInfo(String currentVersion, String latestVersion, String releaseUrl) {}
|
public record UpdateInfo(String currentVersion, String latestVersion, String releaseUrl) {}
|
||||||
|
|
||||||
|
static boolean isPrerelease(String version) {
|
||||||
|
return version.split("\\+", 2)[0].contains("-");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code .../releases/latest} -> {@code .../releases?per_page=30} (prereleases incluses). */
|
||||||
|
static String allReleasesUrl(String latestUrl) {
|
||||||
|
String base = latestUrl.endsWith("/latest") ? latestUrl.substring(0, latestUrl.length() - "/latest".length()) : latestUrl;
|
||||||
|
return base + "?per_page=30";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String version(JsonNode release) {
|
||||||
|
String tag = release.path("tag_name").asText("");
|
||||||
|
return tag.startsWith("v") ? tag.substring(1) : tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Release publiee la plus recente (stable ou beta), brouillons exclus. */
|
||||||
|
@Nullable
|
||||||
|
static JsonNode newestRelease(@Nullable JsonNode releases) {
|
||||||
|
if (releases == null || !releases.isArray()) return null;
|
||||||
|
JsonNode best = null;
|
||||||
|
for (JsonNode r : releases) {
|
||||||
|
if (r.path("draft").asBoolean(false) || version(r).isBlank()) continue;
|
||||||
|
if (best == null || compareVersions(version(best), version(r)) < 0) best = r;
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comme {@link #compareSemver} mais tient compte du suffixe : a version egale,
|
||||||
|
* la stable passe devant la beta (1.5.0-beta < 1.5.0), et deux betas se
|
||||||
|
* comparent par leur numero (1.5.0-beta < 1.5.0-beta.2 < 1.5.0-beta.10).
|
||||||
|
*/
|
||||||
|
static int compareVersions(String a, String b) {
|
||||||
|
int cmp = compareSemver(a, b);
|
||||||
|
if (cmp != 0) return cmp;
|
||||||
|
String sa = suffix(a);
|
||||||
|
String sb = suffix(b);
|
||||||
|
if (sa.isEmpty() || sb.isEmpty()) return Boolean.compare(sa.isEmpty(), sb.isEmpty());
|
||||||
|
return compareSuffixes(sa, sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String suffix(String version) {
|
||||||
|
String noBuild = version.split("\\+", 2)[0];
|
||||||
|
int dash = noBuild.indexOf('-');
|
||||||
|
return dash < 0 ? "" : noBuild.substring(dash + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compare des suffixes en traitant les nombres comme des nombres (beta.10 > beta.2). */
|
||||||
|
private static int compareSuffixes(String a, String b) {
|
||||||
|
String[] pa = a.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)");
|
||||||
|
String[] pb = b.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)");
|
||||||
|
for (int i = 0; i < Math.min(pa.length, pb.length); i++) {
|
||||||
|
boolean na = Character.isDigit(pa[i].charAt(0));
|
||||||
|
boolean nb = Character.isDigit(pb[i].charAt(0));
|
||||||
|
int cmp = na && nb ? Long.compare(Long.parseLong(pa[i]), Long.parseLong(pb[i])) : pa[i].compareTo(pb[i]);
|
||||||
|
if (cmp != 0) return cmp;
|
||||||
|
}
|
||||||
|
return Integer.compare(pa.length, pb.length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare deux versions MAJOR.MINOR.PATCH (suffixe -beta/-rc ignore).
|
* Compare deux versions MAJOR.MINOR.PATCH (suffixe -beta/-rc ignore).
|
||||||
* @return <0 si a<b, 0 si egales, >0 si a>b.
|
* @return <0 si a<b, 0 si egales, >0 si a>b.
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
package com.loremind.infrastructure.licensing;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
import com.loremind.domain.licensing.ports.DockerConfigWriter;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.attribute.PosixFilePermissions;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation : ecriture du fichier {@code config.json} au format Docker
|
|
||||||
* standard, dans un volume partage avec Watchtower.
|
|
||||||
* <p>
|
|
||||||
* Format produit :
|
|
||||||
* <pre>{@code
|
|
||||||
* {
|
|
||||||
* "auths": {
|
|
||||||
* "ghcr.io": {
|
|
||||||
* "auth": "<base64(username:password)>"
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }</pre>
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class FileDockerConfigWriter implements DockerConfigWriter {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(FileDockerConfigWriter.class);
|
|
||||||
|
|
||||||
/** Cle racine du config.json Docker portant les registres authentifies. */
|
|
||||||
private static final String AUTHS_KEY = "auths";
|
|
||||||
|
|
||||||
private final Path configPath;
|
|
||||||
private final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
public FileDockerConfigWriter(
|
|
||||||
@Value("${licensing.docker-config-path:/shared/docker/config.json}") String pathStr) {
|
|
||||||
this.configPath = Path.of(pathStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeCredentials(RegistryCredentials credentials) throws IOException {
|
|
||||||
ensureParentDirectory();
|
|
||||||
|
|
||||||
ObjectNode root;
|
|
||||||
if (Files.exists(configPath)) {
|
|
||||||
try {
|
|
||||||
JsonNode existing = mapper.readTree(configPath.toFile());
|
|
||||||
root = existing.isObject() ? (ObjectNode) existing : mapper.createObjectNode();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Existing docker config unreadable, overwriting: {}", e.getMessage());
|
|
||||||
root = mapper.createObjectNode();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
root = mapper.createObjectNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectNode auths = root.has(AUTHS_KEY) && root.get(AUTHS_KEY).isObject()
|
|
||||||
? (ObjectNode) root.get(AUTHS_KEY)
|
|
||||||
: root.putObject(AUTHS_KEY);
|
|
||||||
|
|
||||||
String b64 = Base64.getEncoder().encodeToString(
|
|
||||||
(credentials.username() + ":" + credentials.password()).getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
ObjectNode entry = mapper.createObjectNode();
|
|
||||||
entry.put("auth", b64);
|
|
||||||
auths.set(credentials.registry(), entry);
|
|
||||||
|
|
||||||
Files.writeString(configPath, mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root),
|
|
||||||
StandardCharsets.UTF_8);
|
|
||||||
applyRestrictivePermissions();
|
|
||||||
log.info("Docker config written at {} for registry {}", configPath, credentials.registry());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() throws IOException {
|
|
||||||
if (Files.exists(configPath)) {
|
|
||||||
Files.delete(configPath);
|
|
||||||
log.info("Docker config cleared at {}", configPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPresent() {
|
|
||||||
return Files.exists(configPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureParentDirectory() throws IOException {
|
|
||||||
Path parent = configPath.getParent();
|
|
||||||
if (parent != null && !Files.exists(parent)) {
|
|
||||||
Files.createDirectories(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 0600 sur POSIX. Sur Windows (dev), no-op silencieux. */
|
|
||||||
private void applyRestrictivePermissions() {
|
|
||||||
try {
|
|
||||||
Files.setPosixFilePermissions(configPath, PosixFilePermissions.fromString("rw-------"));
|
|
||||||
} catch (UnsupportedOperationException | IOException e) {
|
|
||||||
// Windows / FS qui ne supporte pas POSIX => ignore (le conteneur tourne sous Linux en prod)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
package com.loremind.infrastructure.licensing;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
import com.loremind.domain.licensing.ports.LicenseRelay;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
import org.springframework.web.client.HttpServerErrorException;
|
|
||||||
import org.springframework.web.client.RestClientException;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Client HTTP du relais OAuth Patreon (deploye sur Cloudflare Workers).
|
|
||||||
* Voir {@code relay/} pour le code du relais.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class HttpLicenseRelay implements LicenseRelay {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(HttpLicenseRelay.class);
|
|
||||||
|
|
||||||
private final RestTemplate http;
|
|
||||||
private final String baseUrl;
|
|
||||||
|
|
||||||
public HttpLicenseRelay(
|
|
||||||
RestTemplateBuilder builder,
|
|
||||||
@Value("${licensing.relay.base-url:}") String baseUrl) {
|
|
||||||
this.http = builder
|
|
||||||
.connectTimeout(Duration.ofSeconds(5))
|
|
||||||
.readTimeout(Duration.ofSeconds(15))
|
|
||||||
.build();
|
|
||||||
this.baseUrl = stripTrailingSlash(baseUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String buildConnectUrl(String instanceId) {
|
|
||||||
if (baseUrl.isBlank()) {
|
|
||||||
throw new IllegalStateException("Licensing relay base URL not configured");
|
|
||||||
}
|
|
||||||
String encoded = URLEncoder.encode(instanceId, StandardCharsets.UTF_8);
|
|
||||||
return baseUrl + "/oauth/start?instance_id=" + encoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String refreshToken(String currentJwt) throws RelayException {
|
|
||||||
if (baseUrl.isBlank()) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT, "relay not configured");
|
|
||||||
}
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
Map<String, String> body = Map.of("jwt", currentJwt);
|
|
||||||
|
|
||||||
ResponseEntity<JsonNode> resp;
|
|
||||||
try {
|
|
||||||
resp = http.exchange(
|
|
||||||
baseUrl + "/token/refresh",
|
|
||||||
HttpMethod.POST,
|
|
||||||
new HttpEntity<>(body, headers),
|
|
||||||
JsonNode.class);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.REJECTED,
|
|
||||||
"relay rejected refresh: " + e.getStatusCode() + " " + e.getStatusText());
|
|
||||||
} catch (HttpServerErrorException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT,
|
|
||||||
"relay 5xx: " + e.getStatusCode());
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT, "relay unreachable: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonNode payload = resp.getBody();
|
|
||||||
if (payload == null || !payload.hasNonNull("jwt")) {
|
|
||||||
throw new RelayException(RelayErrorKind.BAD_RESPONSE, "missing jwt in refresh response");
|
|
||||||
}
|
|
||||||
return payload.get("jwt").asText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RegistryCredentials fetchRegistryCredentials(String currentJwt) throws RelayException {
|
|
||||||
if (baseUrl.isBlank()) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT, "relay not configured");
|
|
||||||
}
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
Map<String, String> body = Map.of("jwt", currentJwt);
|
|
||||||
|
|
||||||
ResponseEntity<JsonNode> resp;
|
|
||||||
try {
|
|
||||||
resp = http.exchange(
|
|
||||||
baseUrl + "/registry/credentials",
|
|
||||||
HttpMethod.POST,
|
|
||||||
new HttpEntity<>(body, headers),
|
|
||||||
JsonNode.class);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.REJECTED,
|
|
||||||
"relay rejected creds: " + e.getStatusCode() + " " + e.getStatusText());
|
|
||||||
} catch (HttpServerErrorException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT,
|
|
||||||
"relay 5xx: " + e.getStatusCode());
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
throw new RelayException(RelayErrorKind.TRANSIENT, "relay unreachable: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonNode payload = resp.getBody();
|
|
||||||
if (payload == null
|
|
||||||
|| !payload.hasNonNull("registry")
|
|
||||||
|| !payload.hasNonNull("username")
|
|
||||||
|| !payload.hasNonNull("password")) {
|
|
||||||
throw new RelayException(RelayErrorKind.BAD_RESPONSE, "incomplete credentials response");
|
|
||||||
}
|
|
||||||
Instant expiresAt = null;
|
|
||||||
if (payload.hasNonNull("expires_at")) {
|
|
||||||
try {
|
|
||||||
expiresAt = Instant.parse(payload.get("expires_at").asText());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("Cannot parse expires_at from relay creds response: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new RegistryCredentials(
|
|
||||||
payload.get("registry").asText(),
|
|
||||||
payload.get("username").asText(),
|
|
||||||
payload.get("password").asText(),
|
|
||||||
expiresAt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String stripTrailingSlash(String s) {
|
|
||||||
if (s == null) return "";
|
|
||||||
String v = s.trim();
|
|
||||||
if (v.endsWith("/")) v = v.substring(0, v.length() - 1);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package com.loremind.infrastructure.licensing;
|
|
||||||
|
|
||||||
import com.loremind.application.licensing.LicenseService;
|
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
|
||||||
import com.loremind.domain.licensing.LicenseStatus;
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
import com.loremind.domain.licensing.ports.DockerConfigWriter;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Daemon planifie qui :
|
|
||||||
* <ul>
|
|
||||||
* <li>renouvelle le JWT licence via le relais avant expiration (J-2)</li>
|
|
||||||
* <li>met a jour les credentials registry GHCR pour Watchtower
|
|
||||||
* (volume partage docker-config) tant que le canal beta est ON</li>
|
|
||||||
* <li>nettoie les credentials si la licence est invalidee ou le toggle OFF</li>
|
|
||||||
* </ul>
|
|
||||||
* Idempotent : peut tourner toutes les 6h sans risque, fait du no-op
|
|
||||||
* la plupart du temps.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
// Desactivable (ex: tests) : sans cette propriete (prod), le daemon tourne.
|
|
||||||
@ConditionalOnProperty(name = "licensing.refresh.enabled", matchIfMissing = true)
|
|
||||||
public class LicenseRefreshDaemon {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LicenseRefreshDaemon.class);
|
|
||||||
|
|
||||||
/** 6 heures entre chaque cycle. Suffisant pour rattraper un J-2 sans surcharger. */
|
|
||||||
private static final long FIXED_DELAY_MS = 6L * 60L * 60L * 1000L;
|
|
||||||
/** Premier run apres 30s pour laisser le contexte Spring se stabiliser. */
|
|
||||||
private static final long INITIAL_DELAY_MS = 30_000L;
|
|
||||||
|
|
||||||
private final LicenseService licenseService;
|
|
||||||
private final DockerConfigWriter dockerConfigWriter;
|
|
||||||
|
|
||||||
public LicenseRefreshDaemon(LicenseService licenseService,
|
|
||||||
DockerConfigWriter dockerConfigWriter) {
|
|
||||||
this.licenseService = licenseService;
|
|
||||||
this.dockerConfigWriter = dockerConfigWriter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(initialDelay = INITIAL_DELAY_MS, fixedDelay = FIXED_DELAY_MS)
|
|
||||||
public void tick() {
|
|
||||||
if (!licenseService.isLicensingEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
licenseService.refreshIfNeeded();
|
|
||||||
syncDockerConfig();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("LicenseRefreshDaemon tick failed: {}", e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Aligne le fichier docker config avec l'etat de la licence et le toggle :
|
|
||||||
* <ul>
|
|
||||||
* <li>VALID/GRACE + beta ON -> ecrit/refresh les creds</li>
|
|
||||||
* <li>tout autre cas -> efface le fichier</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
private void syncDockerConfig() {
|
|
||||||
LicenseSnapshot snap = licenseService.getCurrentSnapshot();
|
|
||||||
boolean shouldHaveCreds = snap.betaChannelEnabled()
|
|
||||||
&& (snap.status() == LicenseStatus.VALID || snap.status() == LicenseStatus.GRACE);
|
|
||||||
|
|
||||||
if (!shouldHaveCreds) {
|
|
||||||
try {
|
|
||||||
if (dockerConfigWriter.isPresent()) {
|
|
||||||
dockerConfigWriter.clear();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Cannot clear docker config: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<RegistryCredentials> creds = licenseService.fetchRegistryCredentials();
|
|
||||||
if (creds.isEmpty()) {
|
|
||||||
log.warn("Beta enabled but cannot fetch registry credentials (relay down or rejected)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dockerConfigWriter.writeCredentials(creds.get());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Cannot write docker config: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
package com.loremind.infrastructure.licensing;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.LicenseClaims;
|
|
||||||
import com.loremind.domain.licensing.ports.JwtVerifier;
|
|
||||||
import com.nimbusds.jose.JWSAlgorithm;
|
|
||||||
import com.nimbusds.jose.JWSVerifier;
|
|
||||||
import com.nimbusds.jose.crypto.Ed25519Verifier;
|
|
||||||
import com.nimbusds.jose.jwk.OctetKeyPair;
|
|
||||||
import com.nimbusds.jwt.JWTClaimsSet;
|
|
||||||
import com.nimbusds.jwt.SignedJWT;
|
|
||||||
import org.bouncycastle.asn1.ASN1Primitive;
|
|
||||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifie les JWT EdDSA/Ed25519 emis par le relais Patreon.
|
|
||||||
* <p>
|
|
||||||
* La cle publique est fournie en PEM SPKI via la propriete
|
|
||||||
* {@code licensing.jwt.public-key} (env {@code LICENSING_JWT_PUBLIC_KEY}).
|
|
||||||
* Si la cle est absente ou invalide, {@link #isConfigured()} retourne false
|
|
||||||
* et {@link #verify} echoue systematiquement — la feature licensing est
|
|
||||||
* desactivee silencieusement.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class NimbusJwtVerifier implements JwtVerifier {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(NimbusJwtVerifier.class);
|
|
||||||
|
|
||||||
private final String expectedIssuer;
|
|
||||||
private final String expectedAudience;
|
|
||||||
private final OctetKeyPair publicKey;
|
|
||||||
|
|
||||||
public NimbusJwtVerifier(
|
|
||||||
@Value("${licensing.jwt.public-key:}") String publicKeyPemFromEnv,
|
|
||||||
@Value("${licensing.jwt.expected-issuer:loremind-auth}") String expectedIssuer,
|
|
||||||
@Value("${licensing.jwt.expected-audience:loremind-instance}") String expectedAudience) {
|
|
||||||
this.expectedIssuer = expectedIssuer;
|
|
||||||
this.expectedAudience = expectedAudience;
|
|
||||||
// Strategie : env var en priorite (rotation possible sans rebuild),
|
|
||||||
// sinon ressource classpath embarquee dans le binaire.
|
|
||||||
String pem = (publicKeyPemFromEnv != null && !publicKeyPemFromEnv.isBlank())
|
|
||||||
? publicKeyPemFromEnv
|
|
||||||
: loadEmbeddedKey();
|
|
||||||
this.publicKey = parsePemSpki(pem);
|
|
||||||
if (publicKey == null) {
|
|
||||||
log.info("Licensing JWT verifier disabled (no public key found)");
|
|
||||||
} else {
|
|
||||||
String source = (publicKeyPemFromEnv != null && !publicKeyPemFromEnv.isBlank()) ? "env" : "embedded";
|
|
||||||
log.info("Licensing JWT verifier enabled (issuer={}, audience={}, key source={})",
|
|
||||||
expectedIssuer, expectedAudience, source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Charge la cle publique embarquee dans le binaire (resource classpath).
|
|
||||||
* Le fichier est un PEM SPKI standard, fourni a la build pour chaque
|
|
||||||
* release. Si absent, la feature licensing est desactivee.
|
|
||||||
*/
|
|
||||||
private static String loadEmbeddedKey() {
|
|
||||||
ClassPathResource resource = new ClassPathResource("licensing/jwt-public-key.pem");
|
|
||||||
if (!resource.exists()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try (InputStream in = resource.getInputStream()) {
|
|
||||||
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Cannot read embedded JWT public key: {}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConfigured() {
|
|
||||||
return publicKey != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LicenseClaims verify(String rawJwt) throws JwtVerificationException {
|
|
||||||
ensureConfigured();
|
|
||||||
ensureNotBlank(rawJwt);
|
|
||||||
|
|
||||||
SignedJWT signed = parseJwt(rawJwt);
|
|
||||||
ensureExpectedAlgorithm(signed);
|
|
||||||
verifySignature(signed);
|
|
||||||
|
|
||||||
JWTClaimsSet claims = parseClaims(signed);
|
|
||||||
ensureExpectedIssuer(claims);
|
|
||||||
ensureExpectedAudience(claims);
|
|
||||||
|
|
||||||
return toLicenseClaims(claims);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureConfigured() throws JwtVerificationException {
|
|
||||||
if (publicKey == null) {
|
|
||||||
throw new JwtVerificationException("JWT verifier not configured");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ensureNotBlank(String rawJwt) throws JwtVerificationException {
|
|
||||||
if (rawJwt == null || rawJwt.isBlank()) {
|
|
||||||
throw new JwtVerificationException("JWT is empty");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SignedJWT parseJwt(String rawJwt) throws JwtVerificationException {
|
|
||||||
try {
|
|
||||||
return SignedJWT.parse(rawJwt);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new JwtVerificationException("JWT parse error: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ensureExpectedAlgorithm(SignedJWT signed) throws JwtVerificationException {
|
|
||||||
JWSAlgorithm alg = signed.getHeader().getAlgorithm();
|
|
||||||
if (!JWSAlgorithm.EdDSA.equals(alg)) {
|
|
||||||
throw new JwtVerificationException("Unexpected JWT algorithm: " + alg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifySignature(SignedJWT signed) throws JwtVerificationException {
|
|
||||||
try {
|
|
||||||
JWSVerifier verifier = new Ed25519Verifier(publicKey);
|
|
||||||
if (!signed.verify(verifier)) {
|
|
||||||
throw new JwtVerificationException("JWT signature invalid");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new JwtVerificationException("JWT signature verification failed: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JWTClaimsSet parseClaims(SignedJWT signed) throws JwtVerificationException {
|
|
||||||
try {
|
|
||||||
return signed.getJWTClaimsSet();
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new JwtVerificationException("JWT claims parse error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureExpectedIssuer(JWTClaimsSet claims) throws JwtVerificationException {
|
|
||||||
if (!expectedIssuer.equals(claims.getIssuer())) {
|
|
||||||
throw new JwtVerificationException("JWT issuer mismatch: " + claims.getIssuer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureExpectedAudience(JWTClaimsSet claims) throws JwtVerificationException {
|
|
||||||
if (claims.getAudience() == null || !claims.getAudience().contains(expectedAudience)) {
|
|
||||||
throw new JwtVerificationException("JWT audience mismatch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construit les LicenseClaims depuis les claims validés (issuer/audience/signature).
|
|
||||||
* Note : on ne refuse pas un JWT expiré ici. C'est au LicenseService de decider ce
|
|
||||||
* qu'il fait d'un JWT expire (grace period, refresh, etc.). La verification de
|
|
||||||
* signature reste valide tant que la cle existe.
|
|
||||||
*/
|
|
||||||
private static LicenseClaims toLicenseClaims(JWTClaimsSet claims) throws JwtVerificationException {
|
|
||||||
// Nimbus n'expose exp/iat qu'en java.util.Date : converti en Instant SANS variable
|
|
||||||
// Date intermediaire (aucune reference au type legacy dans cette classe).
|
|
||||||
String sub = claims.getSubject();
|
|
||||||
if (claims.getExpirationTime() == null || claims.getIssueTime() == null || sub == null) {
|
|
||||||
throw new JwtVerificationException("JWT missing required claims");
|
|
||||||
}
|
|
||||||
Instant exp = claims.getExpirationTime().toInstant();
|
|
||||||
Instant iat = claims.getIssueTime().toInstant();
|
|
||||||
|
|
||||||
String tierId;
|
|
||||||
String instanceId;
|
|
||||||
try {
|
|
||||||
tierId = claims.getStringClaim("tier_id");
|
|
||||||
instanceId = claims.getStringClaim("instance_id");
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new JwtVerificationException("JWT custom claim parse error", e);
|
|
||||||
}
|
|
||||||
if (tierId == null || tierId.isBlank() || instanceId == null || instanceId.isBlank()) {
|
|
||||||
throw new JwtVerificationException("JWT missing tier_id or instance_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LicenseClaims(sub, tierId, instanceId, iat, exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse une cle publique Ed25519 au format PEM SPKI vers un Nimbus
|
|
||||||
* {@link OctetKeyPair} (forme JWK utilisee pour la verification).
|
|
||||||
*/
|
|
||||||
private static OctetKeyPair parsePemSpki(String pem) {
|
|
||||||
if (pem == null || pem.isBlank()) return null;
|
|
||||||
try {
|
|
||||||
String base64 = pem
|
|
||||||
.replace("-----BEGIN PUBLIC KEY-----", "")
|
|
||||||
.replace("-----END PUBLIC KEY-----", "")
|
|
||||||
.replaceAll("\\s+", "");
|
|
||||||
byte[] der = Base64.getDecoder().decode(base64);
|
|
||||||
SubjectPublicKeyInfo spki = SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(der));
|
|
||||||
byte[] keyBytes = spki.getPublicKeyData().getOctets();
|
|
||||||
String x = Base64.getUrlEncoder().withoutPadding().encodeToString(keyBytes);
|
|
||||||
return new OctetKeyPair.Builder(com.nimbusds.jose.jwk.Curve.Ed25519, com.nimbusds.jose.util.Base64URL.from(x))
|
|
||||||
.build();
|
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
|
||||||
log.warn("Cannot parse licensing JWT public key: {}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
package com.loremind.infrastructure.persistence.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entite JPA pour la licence Patreon installee.
|
|
||||||
* <p>
|
|
||||||
* Singleton : une seule ligne par instance (id = "current"). Ce design permet
|
|
||||||
* de ne jamais avoir de licence "fantome" en base et de simplifier les queries.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "licenses")
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class LicenseJpaEntity {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Column(name = "raw_jwt", columnDefinition = "TEXT", nullable = false)
|
|
||||||
private String rawJwt;
|
|
||||||
|
|
||||||
@Column(name = "patreon_user_id", nullable = false)
|
|
||||||
private String patreonUserId;
|
|
||||||
|
|
||||||
@Column(name = "tier_id", nullable = false)
|
|
||||||
private String tierId;
|
|
||||||
|
|
||||||
@Column(name = "instance_id", nullable = false)
|
|
||||||
private String instanceId;
|
|
||||||
|
|
||||||
@Column(name = "issued_at", nullable = false)
|
|
||||||
private Instant issuedAt;
|
|
||||||
|
|
||||||
@Column(name = "expires_at", nullable = false)
|
|
||||||
private Instant expiresAt;
|
|
||||||
|
|
||||||
@Column(name = "last_refresh_attempt_at")
|
|
||||||
private Instant lastRefreshAttemptAt;
|
|
||||||
|
|
||||||
@Column(name = "last_refresh_succeeded", nullable = false)
|
|
||||||
private boolean lastRefreshSucceeded;
|
|
||||||
|
|
||||||
@Column(name = "beta_channel_enabled", nullable = false)
|
|
||||||
private boolean betaChannelEnabled;
|
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false, updatable = false)
|
|
||||||
private Instant createdAt;
|
|
||||||
|
|
||||||
@Column(name = "updated_at", nullable = false)
|
|
||||||
private Instant updatedAt;
|
|
||||||
|
|
||||||
@PrePersist
|
|
||||||
protected void onCreate() {
|
|
||||||
Instant now = Instant.now();
|
|
||||||
if (createdAt == null) createdAt = now;
|
|
||||||
updatedAt = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreUpdate
|
|
||||||
protected void onUpdate() {
|
|
||||||
updatedAt = Instant.now();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.loremind.infrastructure.persistence.jpa;
|
|
||||||
|
|
||||||
import com.loremind.infrastructure.persistence.entity.LicenseJpaEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface LicenseJpaRepository extends JpaRepository<LicenseJpaEntity, String> {
|
|
||||||
}
|
|
||||||
-76
@@ -1,76 +0,0 @@
|
|||||||
package com.loremind.infrastructure.persistence.postgres;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.License;
|
|
||||||
import com.loremind.domain.licensing.ports.LicenseRepository;
|
|
||||||
import com.loremind.infrastructure.persistence.entity.LicenseJpaEntity;
|
|
||||||
import com.loremind.infrastructure.persistence.jpa.LicenseJpaRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class PostgresLicenseRepository implements LicenseRepository {
|
|
||||||
|
|
||||||
static final String CURRENT_ID = "current";
|
|
||||||
|
|
||||||
private final LicenseJpaRepository jpa;
|
|
||||||
|
|
||||||
public PostgresLicenseRepository(LicenseJpaRepository jpa) {
|
|
||||||
this.jpa = jpa;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<License> findCurrent() {
|
|
||||||
return jpa.findById(CURRENT_ID).map(this::toDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public License save(License license) {
|
|
||||||
LicenseJpaEntity entity = toEntity(license);
|
|
||||||
if (entity.getCreatedAt() == null) {
|
|
||||||
entity.setCreatedAt(Instant.now());
|
|
||||||
}
|
|
||||||
LicenseJpaEntity saved = jpa.save(entity);
|
|
||||||
return toDomain(saved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteCurrent() {
|
|
||||||
jpa.deleteById(CURRENT_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private License toDomain(LicenseJpaEntity e) {
|
|
||||||
return License.builder()
|
|
||||||
.id(e.getId())
|
|
||||||
.rawJwt(e.getRawJwt())
|
|
||||||
.patreonUserId(e.getPatreonUserId())
|
|
||||||
.tierId(e.getTierId())
|
|
||||||
.instanceId(e.getInstanceId())
|
|
||||||
.issuedAt(e.getIssuedAt())
|
|
||||||
.expiresAt(e.getExpiresAt())
|
|
||||||
.lastRefreshAttemptAt(e.getLastRefreshAttemptAt())
|
|
||||||
.lastRefreshSucceeded(e.isLastRefreshSucceeded())
|
|
||||||
.betaChannelEnabled(e.isBetaChannelEnabled())
|
|
||||||
.createdAt(e.getCreatedAt())
|
|
||||||
.updatedAt(e.getUpdatedAt())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private LicenseJpaEntity toEntity(License l) {
|
|
||||||
return LicenseJpaEntity.builder()
|
|
||||||
.id(CURRENT_ID)
|
|
||||||
.rawJwt(l.getRawJwt())
|
|
||||||
.patreonUserId(l.getPatreonUserId())
|
|
||||||
.tierId(l.getTierId())
|
|
||||||
.instanceId(l.getInstanceId())
|
|
||||||
.issuedAt(l.getIssuedAt())
|
|
||||||
.expiresAt(l.getExpiresAt())
|
|
||||||
.lastRefreshAttemptAt(l.getLastRefreshAttemptAt())
|
|
||||||
.lastRefreshSucceeded(l.isLastRefreshSucceeded())
|
|
||||||
.betaChannelEnabled(l.isBetaChannelEnabled())
|
|
||||||
.createdAt(l.getCreatedAt())
|
|
||||||
.updatedAt(l.getUpdatedAt())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.loremind.infrastructure.updates;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire les identifiants GHCR laisses par l'ancien canal beta Patreon.
|
||||||
|
*
|
||||||
|
* <p>Jusqu'a la 1.5, le Core ecrivait un {@code config.json} Docker (jeton GHCR recu
|
||||||
|
* du relais Patreon) dans un volume partage avec Watchtower et le switcher. Le canal
|
||||||
|
* beta est desormais libre et ses images publiques : ce jeton ne sert plus, et une
|
||||||
|
* fois revoque il ferait ECHOUER les telechargements (un registry refuse des
|
||||||
|
* identifiants invalides, meme pour une image publique). Le fichier n'a jamais
|
||||||
|
* contenu que ces identifiants : on le supprime au demarrage.
|
||||||
|
*
|
||||||
|
* <p>No-op sur les installations recentes : le docker-compose.yml ne monte plus ce
|
||||||
|
* volume ni ne definit {@code LICENSING_DOCKER_CONFIG_PATH}.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class LegacyRegistryCredentialsCleanup implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(LegacyRegistryCredentialsCleanup.class);
|
||||||
|
|
||||||
|
private final String configPath;
|
||||||
|
|
||||||
|
public LegacyRegistryCredentialsCleanup(@Value("${LICENSING_DOCKER_CONFIG_PATH:}") String configPath) {
|
||||||
|
this.configPath = configPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return true si un ancien fichier d'identifiants a ete supprime */
|
||||||
|
boolean cleanup() {
|
||||||
|
if (configPath == null || configPath.isBlank()) return false;
|
||||||
|
Path file = Path.of(configPath);
|
||||||
|
try {
|
||||||
|
if (Files.deleteIfExists(file)) {
|
||||||
|
log.info("[Updates] Anciens identifiants GHCR du canal beta supprimes ({}).", file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (IOException | SecurityException e) {
|
||||||
|
log.warn("[Updates] Impossible de supprimer les anciens identifiants GHCR ({}) : {}", file, e.getMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.loremind.infrastructure.updates;
|
package com.loremind.infrastructure.updates;
|
||||||
|
|
||||||
import com.loremind.application.licensing.LicenseService;
|
import com.loremind.application.channel.ChannelSwitcherService;
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
import com.loremind.application.channel.ChannelSwitcherService.Channel;
|
||||||
import com.loremind.domain.licensing.LicenseStatus;
|
|
||||||
import com.loremind.domain.licensing.RegistryCredentials;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -24,10 +22,8 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detection des mises a jour disponibles + declenchement via Watchtower.
|
* Detection des mises a jour disponibles + declenchement via Watchtower.
|
||||||
@@ -59,8 +55,9 @@ public class UpdateCheckService {
|
|||||||
private final List<String> images;
|
private final List<String> images;
|
||||||
private final String watchtowerUrl;
|
private final String watchtowerUrl;
|
||||||
private final String watchtowerToken;
|
private final String watchtowerToken;
|
||||||
|
private final String betaRegistry;
|
||||||
private final List<String> betaImages;
|
private final List<String> betaImages;
|
||||||
private final LicenseService licenseService;
|
private final ChannelSwitcherService channels;
|
||||||
/** Version semver courante du binaire (ex: "0.8.0"). Source de verite. */
|
/** Version semver courante du binaire (ex: "0.8.0"). Source de verite. */
|
||||||
private final String currentVersion;
|
private final String currentVersion;
|
||||||
|
|
||||||
@@ -70,8 +67,9 @@ public class UpdateCheckService {
|
|||||||
@Value("${update-check.images:}") String imagesCsv,
|
@Value("${update-check.images:}") String imagesCsv,
|
||||||
@Value("${update-check.watchtower-url:http://watchtower:8080}") String watchtowerUrl,
|
@Value("${update-check.watchtower-url:http://watchtower:8080}") String watchtowerUrl,
|
||||||
@Value("${update-check.watchtower-token:}") String watchtowerToken,
|
@Value("${update-check.watchtower-token:}") String watchtowerToken,
|
||||||
@Value("${licensing.beta.images:}") String betaImagesCsv,
|
@Value("${update-check.beta-registry:ghcr.io}") String betaRegistry,
|
||||||
LicenseService licenseService,
|
@Value("${update-check.beta-images:}") String betaImagesCsv,
|
||||||
|
ChannelSwitcherService channels,
|
||||||
@Nullable BuildProperties buildProperties) {
|
@Nullable BuildProperties buildProperties) {
|
||||||
this.http = builder
|
this.http = builder
|
||||||
.connectTimeout(Duration.ofSeconds(5))
|
.connectTimeout(Duration.ofSeconds(5))
|
||||||
@@ -81,8 +79,9 @@ public class UpdateCheckService {
|
|||||||
this.images = parseImages(imagesCsv);
|
this.images = parseImages(imagesCsv);
|
||||||
this.watchtowerUrl = watchtowerUrl;
|
this.watchtowerUrl = watchtowerUrl;
|
||||||
this.watchtowerToken = watchtowerToken;
|
this.watchtowerToken = watchtowerToken;
|
||||||
|
this.betaRegistry = normalizeRegistry(betaRegistry);
|
||||||
this.betaImages = parseImages(betaImagesCsv);
|
this.betaImages = parseImages(betaImagesCsv);
|
||||||
this.licenseService = licenseService;
|
this.channels = channels;
|
||||||
this.currentVersion = buildProperties != null ? buildProperties.getVersion() : null;
|
this.currentVersion = buildProperties != null ? buildProperties.getVersion() : null;
|
||||||
log.info("Update check init - registry={} images={} currentVersion={}",
|
log.info("Update check init - registry={} images={} currentVersion={}",
|
||||||
this.registry, this.images, this.currentVersion);
|
this.registry, this.images, this.currentVersion);
|
||||||
@@ -119,33 +118,17 @@ public class UpdateCheckService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifie l'etat du canal beta (images privees GHCR) avec auth basique.
|
* Verifie l'etat du canal beta quand l'instance y tourne. Les images beta sont
|
||||||
|
* publiques (canal libre, plus de licence) : lecture anonyme du registry.
|
||||||
*/
|
*/
|
||||||
public BetaStatus checkBeta() {
|
public BetaStatus checkBeta() {
|
||||||
if (!licenseService.isLicensingEnabled()) {
|
if (channels.getCurrentChannel() != Channel.BETA) {
|
||||||
return BetaStatus.disabled("licensing-not-configured");
|
return BetaStatus.disabled("not-on-beta-channel");
|
||||||
}
|
}
|
||||||
LicenseSnapshot snap = licenseService.getCurrentSnapshot();
|
if (betaImages.isEmpty() || betaRegistry.isEmpty()) {
|
||||||
if (snap.status() != LicenseStatus.VALID && snap.status() != LicenseStatus.GRACE) {
|
|
||||||
return BetaStatus.disabled("license-" + snap.status().name().toLowerCase());
|
|
||||||
}
|
|
||||||
if (!snap.betaChannelEnabled()) {
|
|
||||||
return BetaStatus.disabled("beta-toggle-off");
|
|
||||||
}
|
|
||||||
if (betaImages.isEmpty()) {
|
|
||||||
return BetaStatus.disabled("no-beta-images-configured");
|
return BetaStatus.disabled("no-beta-images-configured");
|
||||||
}
|
}
|
||||||
|
ImagesEvaluation ev = evaluateImages(betaImages, betaRegistry, null);
|
||||||
Optional<RegistryCredentials> creds = licenseService.fetchRegistryCredentials();
|
|
||||||
if (creds.isEmpty()) {
|
|
||||||
return new BetaStatus(true, false, true, List.of(), Instant.now(), "relay-unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
String basicAuth = "Basic " + Base64.getEncoder().encodeToString(
|
|
||||||
(creds.get().username() + ":" + creds.get().password()).getBytes(StandardCharsets.UTF_8));
|
|
||||||
String betaRegistry = normalizeRegistry(creds.get().registry());
|
|
||||||
|
|
||||||
ImagesEvaluation ev = evaluateImages(betaImages, betaRegistry, basicAuth);
|
|
||||||
return new BetaStatus(true, ev.anyUpdate(), ev.anyUnknown(),
|
return new BetaStatus(true, ev.anyUpdate(), ev.anyUnknown(),
|
||||||
ev.statuses(), Instant.now(), null);
|
ev.statuses(), Instant.now(), null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>Important : ne court-circuite PAS les try/catch locaux des controllers
|
* <p>Important : ne court-circuite PAS les try/catch locaux des controllers
|
||||||
* (ex: LicenseController.install catche InstallException -> 400 lui-meme).
|
* (ex: UpdatesController.switchChannel catche IOException -> 500 lui-meme).
|
||||||
* Ce handler n'attrape QUE ce qui a echappe au catch local.
|
* Ce handler n'attrape QUE ce qui a echappe au catch local.
|
||||||
*/
|
*/
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class RemoteAccessFilter extends OncePerRequestFilter {
|
|||||||
private static final List<String> PUBLIC_PATHS = List.of(
|
private static final List<String> PUBLIC_PATHS = List.of(
|
||||||
"/api/config", "/api/version", "/api/remote-access/pair", "/api/remote-access/session");
|
"/api/config", "/api/version", "/api/remote-access/pair", "/api/remote-access/session");
|
||||||
private static final List<String> LOCAL_ONLY_PREFIXES = List.of(
|
private static final List<String> LOCAL_ONLY_PREFIXES = List.of(
|
||||||
"/api/settings", "/api/admin", "/api/license");
|
"/api/settings", "/api/admin");
|
||||||
|
|
||||||
private final RemoteAccessService remoteAccessService;
|
private final RemoteAccessService remoteAccessService;
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ public class SecurityConfig {
|
|||||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
.requestMatchers("/api/settings/**").hasRole(ROLE_ADMIN)
|
.requestMatchers("/api/settings/**").hasRole(ROLE_ADMIN)
|
||||||
.requestMatchers("/api/admin/**").hasRole(ROLE_ADMIN)
|
.requestMatchers("/api/admin/**").hasRole(ROLE_ADMIN)
|
||||||
.requestMatchers("/api/license/**").hasRole(ROLE_ADMIN)
|
|
||||||
.anyRequest().permitAll()
|
.anyRequest().permitAll()
|
||||||
)
|
)
|
||||||
.httpBasic(basic -> {});
|
.httpBasic(basic -> {});
|
||||||
|
|||||||
@@ -1,160 +0,0 @@
|
|||||||
package com.loremind.infrastructure.web.controller;
|
|
||||||
|
|
||||||
import com.loremind.application.licensing.ChannelSwitcherService;
|
|
||||||
import com.loremind.application.licensing.LicenseService;
|
|
||||||
import com.loremind.application.licensing.LicenseService.InstallException;
|
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
|
||||||
import com.loremind.infrastructure.web.dto.licensing.ChannelStatusDTO;
|
|
||||||
import com.loremind.infrastructure.web.dto.licensing.LicenseStatusDTO;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Endpoints de gestion de la licence Patreon.
|
|
||||||
*
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code GET /api/license} : etat courant (status, tier, expiration...)</li>
|
|
||||||
* <li>{@code GET /api/license/connect-url} : URL OAuth a ouvrir dans le navigateur</li>
|
|
||||||
* <li>{@code POST /api/license/install} : colle un JWT recu du relais</li>
|
|
||||||
* <li>{@code DELETE /api/license} : deconnecte Patreon (efface la licence)</li>
|
|
||||||
* <li>{@code POST /api/license/refresh} : force un refresh manuel</li>
|
|
||||||
* <li>{@code PUT /api/license/beta-channel} : active/desactive le canal beta</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/license")
|
|
||||||
public class LicenseController {
|
|
||||||
|
|
||||||
/** Clé du message d'erreur dans le body JSON — contrat lu par le frontend. */
|
|
||||||
private static final String ERROR_KEY = "error";
|
|
||||||
|
|
||||||
private final LicenseService licenseService;
|
|
||||||
private final ChannelSwitcherService channelSwitcher;
|
|
||||||
|
|
||||||
public LicenseController(LicenseService licenseService, ChannelSwitcherService channelSwitcher) {
|
|
||||||
this.licenseService = licenseService;
|
|
||||||
this.channelSwitcher = channelSwitcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public LicenseStatusDTO getStatus() {
|
|
||||||
boolean enabled = licenseService.isLicensingEnabled();
|
|
||||||
LicenseSnapshot snap = licenseService.getCurrentSnapshot();
|
|
||||||
return LicenseStatusDTO.from(enabled, snap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/connect-url")
|
|
||||||
public Map<String, String> getConnectUrl() {
|
|
||||||
return Map.of("url", licenseService.buildConnectUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/install")
|
|
||||||
public ResponseEntity<Object> install(@RequestBody InstallRequest request) {
|
|
||||||
if (request == null || request.jwt() == null || request.jwt().isBlank()) {
|
|
||||||
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, "missing jwt"));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
LicenseSnapshot snap = licenseService.installToken(request.jwt());
|
|
||||||
return ResponseEntity.ok(LicenseStatusDTO.from(true, snap));
|
|
||||||
} catch (InstallException e) {
|
|
||||||
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
public ResponseEntity<Void> disconnect() {
|
|
||||||
licenseService.disconnect();
|
|
||||||
return ResponseEntity.noContent().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/refresh")
|
|
||||||
public ResponseEntity<LicenseStatusDTO> refresh() {
|
|
||||||
licenseService.forceRefresh();
|
|
||||||
boolean enabled = licenseService.isLicensingEnabled();
|
|
||||||
return ResponseEntity.ok(LicenseStatusDTO.from(enabled, licenseService.getCurrentSnapshot()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/beta-channel")
|
|
||||||
public ResponseEntity<Object> setBetaChannel(@RequestBody BetaChannelRequest request) {
|
|
||||||
if (request == null) {
|
|
||||||
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, "missing body"));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
LicenseSnapshot snap = licenseService.setBetaChannelEnabled(request.enabled());
|
|
||||||
return ResponseEntity.ok(LicenseStatusDTO.from(true, snap));
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
return ResponseEntity.status(409).body(Map.of(ERROR_KEY, e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Bascule de canal (stable <-> beta) via sidecar switcher ────────────
|
|
||||||
//
|
|
||||||
// Le flux :
|
|
||||||
// 1. UI POST /api/license/channel/switch { channel: "beta" }
|
|
||||||
// 2. Core valide la licence (refus si target=beta sans Patreon actif)
|
|
||||||
// 3. Core depose une commande dans le volume partage
|
|
||||||
// 4. Sidecar `switcher` la traite (sed .env, docker compose up -d)
|
|
||||||
// 5. UI poll GET /api/license/channel pour suivre le status
|
|
||||||
|
|
||||||
/** Etat courant : canal actuel + dispo du sidecar + dernier resultat. */
|
|
||||||
// S125 : faux positif — le flux numerote ci-dessus est de la prose explicative, pas du code mort.
|
|
||||||
@SuppressWarnings("java:S125")
|
|
||||||
@GetMapping("/channel")
|
|
||||||
public ChannelStatusDTO getChannel() {
|
|
||||||
return ChannelStatusDTO.from(channelSwitcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Declenche un switch de canal. Renvoie l'ID de la commande pour le polling. */
|
|
||||||
@PostMapping("/channel/switch")
|
|
||||||
public ResponseEntity<Object> switchChannel(@RequestBody ChannelSwitchRequest request) {
|
|
||||||
if (request == null || request.channel() == null) {
|
|
||||||
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, "missing channel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelSwitcherService.Channel target;
|
|
||||||
try {
|
|
||||||
target = ChannelSwitcherService.Channel.valueOf(request.channel().toUpperCase(Locale.ROOT));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return ResponseEntity.badRequest().body(Map.of(
|
|
||||||
ERROR_KEY, "invalid channel (allowed: stable, beta)"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Garde : pas de switch vers beta sans licence Patreon valide.
|
|
||||||
// Le switcher ferait le boulot quoi qu'il arrive (il valide juste le
|
|
||||||
// format), donc c'est ici qu'on doit refuser cote metier.
|
|
||||||
// VALID + GRACE autorisent l'acces beta (cf. javadoc de LicenseStatus).
|
|
||||||
if (target == ChannelSwitcherService.Channel.BETA) {
|
|
||||||
LicenseSnapshot snap = licenseService.getCurrentSnapshot();
|
|
||||||
com.loremind.domain.licensing.LicenseStatus s = (snap != null) ? snap.status() : null;
|
|
||||||
boolean allowed = s == com.loremind.domain.licensing.LicenseStatus.VALID
|
|
||||||
|| s == com.loremind.domain.licensing.LicenseStatus.GRACE;
|
|
||||||
if (!allowed) {
|
|
||||||
return ResponseEntity.status(403).body(Map.of(
|
|
||||||
ERROR_KEY, "Aucune licence Patreon active — impossible de basculer sur le canal beta."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!channelSwitcher.isSwitcherAvailable()) {
|
|
||||||
return ResponseEntity.status(503).body(Map.of(
|
|
||||||
ERROR_KEY, "Sidecar switcher non disponible (mise a jour requise du docker-compose.yml)."));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
String id = channelSwitcher.requestSwitch(target);
|
|
||||||
return ResponseEntity.accepted().body(Map.of(
|
|
||||||
"id", id,
|
|
||||||
"channel", target.name().toLowerCase(Locale.ROOT)));
|
|
||||||
} catch (IOException e) {
|
|
||||||
return ResponseEntity.status(500).body(Map.of(
|
|
||||||
ERROR_KEY, "Impossible d'ecrire la commande de switch: " + e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public record InstallRequest(String jwt) {}
|
|
||||||
public record BetaChannelRequest(boolean enabled) {}
|
|
||||||
public record ChannelSwitchRequest(String channel) {}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.loremind.infrastructure.web.controller;
|
package com.loremind.infrastructure.web.controller;
|
||||||
|
|
||||||
|
import com.loremind.application.channel.ChannelSwitcherService;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService;
|
import com.loremind.infrastructure.updates.UpdateCheckService;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.BetaStatus;
|
import com.loremind.infrastructure.updates.UpdateCheckService.BetaStatus;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.UpdateStatus;
|
import com.loremind.infrastructure.updates.UpdateCheckService.UpdateStatus;
|
||||||
@@ -10,10 +11,14 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
import com.loremind.infrastructure.web.dto.updates.ChannelStatusDTO;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,12 +35,18 @@ public class UpdatesController {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(UpdatesController.class);
|
private static final Logger log = LoggerFactory.getLogger(UpdatesController.class);
|
||||||
|
|
||||||
|
/** Clé du message d'erreur dans le body JSON — contrat lu par le frontend. */
|
||||||
|
private static final String ERROR_KEY = "error";
|
||||||
|
|
||||||
private final UpdateCheckService updates;
|
private final UpdateCheckService updates;
|
||||||
|
private final ChannelSwitcherService channels;
|
||||||
private final boolean demoMode;
|
private final boolean demoMode;
|
||||||
|
|
||||||
public UpdatesController(UpdateCheckService updates,
|
public UpdatesController(UpdateCheckService updates,
|
||||||
|
ChannelSwitcherService channels,
|
||||||
@Value("${app.demo-mode:false}") boolean demoMode) {
|
@Value("${app.demo-mode:false}") boolean demoMode) {
|
||||||
this.updates = updates;
|
this.updates = updates;
|
||||||
|
this.channels = channels;
|
||||||
this.demoMode = demoMode;
|
this.demoMode = demoMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +81,50 @@ public class UpdatesController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Bascule de canal stable <-> beta via le sidecar `switcher` ----------
|
||||||
|
//
|
||||||
|
// Le canal beta est libre : toute instance Docker peut y passer et en revenir.
|
||||||
|
// L'UI depose une commande (POST /channel/switch), le sidecar l'applique
|
||||||
|
// (IMAGE_NAMESPACE du .env + docker compose pull/up), l'UI suit le resultat
|
||||||
|
// via GET /channel.
|
||||||
|
|
||||||
|
/** Etat courant : canal actuel + dispo du sidecar + dernier resultat. */
|
||||||
|
@GetMapping("/channel")
|
||||||
|
public ChannelStatusDTO channel() {
|
||||||
|
guardDemoMode();
|
||||||
|
return ChannelStatusDTO.from(channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Declenche un switch de canal. Renvoie l'ID de la commande pour le polling. */
|
||||||
|
@PostMapping("/channel/switch")
|
||||||
|
public ResponseEntity<Object> switchChannel(@RequestBody ChannelSwitchRequest request) {
|
||||||
|
guardDemoMode();
|
||||||
|
if (request == null || request.channel() == null) {
|
||||||
|
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, "missing channel"));
|
||||||
|
}
|
||||||
|
ChannelSwitcherService.Channel target;
|
||||||
|
try {
|
||||||
|
target = ChannelSwitcherService.Channel.valueOf(request.channel().toUpperCase(Locale.ROOT));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return ResponseEntity.badRequest().body(Map.of(ERROR_KEY, "invalid channel (allowed: stable, beta)"));
|
||||||
|
}
|
||||||
|
if (!channels.isSwitcherAvailable()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(Map.of(
|
||||||
|
ERROR_KEY, "Sidecar switcher non disponible (mise a jour requise du docker-compose.yml)."));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String id = channels.requestSwitch(target);
|
||||||
|
return ResponseEntity.accepted().body(Map.of(
|
||||||
|
"id", id,
|
||||||
|
"channel", target.name().toLowerCase(Locale.ROOT)));
|
||||||
|
} catch (IOException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Map.of(
|
||||||
|
ERROR_KEY, "Impossible d'ecrire la commande de switch: " + e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ChannelSwitchRequest(String channel) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* En mode demo, les instances ne doivent pas se mettre a jour ni meme
|
* En mode demo, les instances ne doivent pas se mettre a jour ni meme
|
||||||
* exposer leur statut (pas de surface d'attaque, et pas de redemarrage
|
* exposer leur statut (pas de surface d'attaque, et pas de redemarrage
|
||||||
|
|||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package com.loremind.infrastructure.web.dto.licensing;
|
|
||||||
|
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vue serialisee de l'etat de la licence pour le frontend.
|
|
||||||
* Le {@code rawJwt} n'est volontairement JAMAIS expose.
|
|
||||||
*/
|
|
||||||
public record LicenseStatusDTO(
|
|
||||||
boolean enabled,
|
|
||||||
String status,
|
|
||||||
String patreonUserId,
|
|
||||||
String tierId,
|
|
||||||
String instanceId,
|
|
||||||
Instant expiresAt,
|
|
||||||
Instant lastRefreshAttemptAt,
|
|
||||||
Boolean lastRefreshSucceeded,
|
|
||||||
boolean betaChannelEnabled
|
|
||||||
) {
|
|
||||||
public static LicenseStatusDTO from(boolean enabled, LicenseSnapshot snap) {
|
|
||||||
return new LicenseStatusDTO(
|
|
||||||
enabled,
|
|
||||||
snap.status().name(),
|
|
||||||
snap.patreonUserId(),
|
|
||||||
snap.tierId(),
|
|
||||||
snap.instanceId(),
|
|
||||||
snap.expiresAt(),
|
|
||||||
snap.lastRefreshAttemptAt(),
|
|
||||||
snap.lastRefreshAttemptAt() != null ? snap.lastRefreshSucceeded() : null,
|
|
||||||
snap.betaChannelEnabled()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package com.loremind.infrastructure.web.dto.licensing;
|
package com.loremind.infrastructure.web.dto.updates;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.loremind.application.licensing.ChannelSwitcherService;
|
import com.loremind.application.channel.ChannelSwitcherService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Etat du canal courant + dernier resultat de switch.
|
* Etat du canal courant + dernier resultat de switch.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
# vivent sous loremind.home (defaut : ~/.loremind).
|
# vivent sous loremind.home (defaut : ~/.loremind).
|
||||||
#
|
#
|
||||||
# Surcharge UNIQUEMENT ce qui differe du profil par defaut (application.properties) :
|
# Surcharge UNIQUEMENT ce qui differe du profil par defaut (application.properties) :
|
||||||
# le reste (timeouts, multipart, licensing...) est herite tel quel.
|
# le reste (timeouts, multipart...) est herite tel quel.
|
||||||
|
|
||||||
# --- Config utilisateur editable (port + identifiants admin) ----------------
|
# --- Config utilisateur editable (port + identifiants admin) ----------------
|
||||||
# Charge ~/.loremind/loremind.properties s'il existe (cree au 1er lancement par
|
# Charge ~/.loremind/loremind.properties s'il existe (cree au 1er lancement par
|
||||||
@@ -105,14 +105,6 @@ loremind.upload.max-file-size=2GB
|
|||||||
loremind.upload.max-request-size=2GB
|
loremind.upload.max-request-size=2GB
|
||||||
server.tomcat.max-swallow-size=-1
|
server.tomcat.max-swallow-size=-1
|
||||||
|
|
||||||
# --- Licensing / Patreon : desactive en mode bureau ------------------------
|
|
||||||
# Le gating par IMAGE Docker (canal beta tire d'un registry prive) n'a aucun
|
|
||||||
# sens hors Docker. On coupe toute la machinerie : daemon de refresh no-op,
|
|
||||||
# /api/license/* renvoie enabled=false, et l'UI masque la section Patreon.
|
|
||||||
# La distribution beta desktop se fait par installeur beta via Patreon, pas
|
|
||||||
# par une connexion in-app.
|
|
||||||
licensing.enabled=false
|
|
||||||
|
|
||||||
# --- Verification des mises a jour (bureau) --------------------------------
|
# --- Verification des mises a jour (bureau) --------------------------------
|
||||||
# Interroge l'API GitHub Releases (derniere release STABLE) au demarrage ; si
|
# Interroge l'API GitHub Releases (derniere release STABLE) au demarrage ; si
|
||||||
# une version plus recente existe, l'icone systray le signale (bulle + item
|
# une version plus recente existe, l'icone systray le signale (bulle + item
|
||||||
|
|||||||
@@ -104,36 +104,7 @@ update-check.images=${UPDATE_CHECK_IMAGES:}
|
|||||||
update-check.watchtower-url=${WATCHTOWER_URL:http://watchtower:8080}
|
update-check.watchtower-url=${WATCHTOWER_URL:http://watchtower:8080}
|
||||||
update-check.watchtower-token=${WATCHTOWER_TOKEN:}
|
update-check.watchtower-token=${WATCHTOWER_TOKEN:}
|
||||||
|
|
||||||
# ============================================================================
|
# Canal beta (libre) : images publiques verifiees quand l'instance tourne en beta.
|
||||||
# Licensing (canal beta gate par Patreon)
|
# LICENSING_BETA_IMAGES reste lu pour les .env d'avant la suppression de Patreon.
|
||||||
# ============================================================================
|
update-check.beta-registry=${UPDATE_CHECK_BETA_REGISTRY:ghcr.io}
|
||||||
# URL du relais OAuth Patreon (Cloudflare Workers). En prod : valeur par defaut.
|
update-check.beta-images=${UPDATE_CHECK_BETA_IMAGES:${LICENSING_BETA_IMAGES:igmlcreation/loremind-beta-core,igmlcreation/loremind-beta-brain,igmlcreation/loremind-beta-web}}
|
||||||
licensing.relay.base-url=${LICENSING_RELAY_BASE_URL:https://loremind-auth.igmlcreation.fr}
|
|
||||||
|
|
||||||
# Cle publique Ed25519 (PEM SPKI) qui verifie les JWT emis par le relais.
|
|
||||||
# En prod : chargee automatiquement depuis classpath:licensing/jwt-public-key.pem
|
|
||||||
# (embarquee dans le binaire). Cette propriete sert UNIQUEMENT a la rotation
|
|
||||||
# de cle ou aux tests : si LICENSING_JWT_PUBLIC_KEY est defini, il prevaut
|
|
||||||
# sur le fichier embarque.
|
|
||||||
licensing.jwt.public-key=${LICENSING_JWT_PUBLIC_KEY:}
|
|
||||||
licensing.jwt.expected-issuer=loremind-auth
|
|
||||||
licensing.jwt.expected-audience=loremind-instance
|
|
||||||
|
|
||||||
# Periode de tolerance apres expiration du JWT pendant laquelle l'instance
|
|
||||||
# garde l'acces beta meme si le relais est indisponible pour le refresh.
|
|
||||||
licensing.grace-period-days=14
|
|
||||||
# Avant J-N de l'expiration, le daemon tente un refresh.
|
|
||||||
licensing.refresh-before-expiry-days=2
|
|
||||||
|
|
||||||
# Identifiant stable de l'instance (UUID genere a la premiere connexion Patreon
|
|
||||||
# et conserve en base). Utilise dans le state OAuth + dans le JWT.
|
|
||||||
licensing.instance-id-file=${LICENSING_INSTANCE_ID_FILE:}
|
|
||||||
|
|
||||||
# Image beta : si la licence est valide ET le toggle canal beta active,
|
|
||||||
# UpdateCheckService check ces images en plus du canal stable.
|
|
||||||
licensing.beta.images=${LICENSING_BETA_IMAGES:igmlcreation/loremind-beta-core,igmlcreation/loremind-beta-brain,igmlcreation/loremind-beta-web}
|
|
||||||
|
|
||||||
# Chemin de sortie pour le docker config.json partage avec Watchtower.
|
|
||||||
# Volume Docker `docker-config` monte sur ce chemin dans Core, et sur
|
|
||||||
# `/shared/docker` dans Watchtower (DOCKER_CONFIG=/shared/docker).
|
|
||||||
licensing.docker-config-path=${LICENSING_DOCKER_CONFIG_PATH:/shared/docker/config.json}
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- Le canal beta est libre : plus de licence Patreon, la table des licences ne sert plus.
|
||||||
|
DROP TABLE IF EXISTS licenses;
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Cle publique JWT du relais OAuth Patreon
|
|
||||||
|
|
||||||
Le fichier `jwt-public-key.pem` contient la **cle publique Ed25519** qui sert
|
|
||||||
a verifier la signature des JWT licence emis par le relais
|
|
||||||
(`loremind-auth.igmlcreation.fr`).
|
|
||||||
|
|
||||||
## Pourquoi ici ?
|
|
||||||
|
|
||||||
- C'est une **cle publique** : par nature non-secrete, elle peut etre committee
|
|
||||||
dans le repo public et embarquee dans le binaire distribue.
|
|
||||||
- Cela evite a chaque utilisateur final de devoir renseigner manuellement la
|
|
||||||
cle dans son `.env` au moment de l'installation.
|
|
||||||
- L'env `LICENSING_JWT_PUBLIC_KEY` peut surcharger cette valeur (utile pour
|
|
||||||
la rotation de cle sans rebuild ou pour les tests).
|
|
||||||
|
|
||||||
## Si le fichier est absent
|
|
||||||
|
|
||||||
La feature licensing est **desactivee silencieusement** : `LicenseService.isLicensingEnabled()`
|
|
||||||
renvoie `false`, et l'UI masque toute la section Patreon.
|
|
||||||
|
|
||||||
## Rotation de cle
|
|
||||||
|
|
||||||
1. Generer une nouvelle paire dans le relais : `npm run keys:generate`
|
|
||||||
2. Pousser la nouvelle cle privee : `wrangler secret put JWT_PRIVATE_KEY`
|
|
||||||
3. Remplacer `jwt-public-key.pem` ici avec la nouvelle cle publique
|
|
||||||
4. Rebuild + redeployer LoreMind (les anciens JWT seront refuses au prochain
|
|
||||||
refresh, l'utilisateur sera invite a reconnecter Patreon)
|
|
||||||
5. Optionnel : pendant la transition, supporter les deux cles en parallele
|
|
||||||
(pas implemente en MVP, peut etre ajoute si besoin operationnel)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MCowBQYDK2VwAyEArbfaqBq54HJR1pKqliTShKrNIab32gpBwSTDw90I4wg=
|
|
||||||
-----END PUBLIC KEY-----
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package com.loremind.infrastructure.desktop;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.info.BuildProperties;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mises a jour du bureau : la version stable suit {@code /releases/latest} ; une version
|
||||||
|
* beta (canal libre, publie en prerelease GitHub) suit la liste complete des releases.
|
||||||
|
*/
|
||||||
|
class DesktopUpdateServiceTest {
|
||||||
|
|
||||||
|
private static final String LATEST = "https://api.github.com/repos/IGMLcreation/LoreMind/releases/latest";
|
||||||
|
private static final String ALL = "https://api.github.com/repos/IGMLcreation/LoreMind/releases?per_page=30";
|
||||||
|
private static final ObjectMapper JSON = new ObjectMapper();
|
||||||
|
|
||||||
|
private static DesktopUpdateService service(String currentVersion, RestTemplate http) {
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.setProperty("version", currentVersion);
|
||||||
|
DesktopUpdateService svc = new DesktopUpdateService(new RestTemplateBuilder(), true, LATEST, new BuildProperties(p));
|
||||||
|
ReflectionTestUtils.setField(svc, "http", http);
|
||||||
|
return svc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void reply(RestTemplate http, String url, String json) throws Exception {
|
||||||
|
JsonNode body = JSON.readTree(json);
|
||||||
|
when(http.exchange(eq(url), eq(HttpMethod.GET), any(), eq(JsonNode.class)))
|
||||||
|
.thenReturn(ResponseEntity.ok(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void stableVersion_followsTheLatestStableRelease() throws Exception {
|
||||||
|
RestTemplate http = mock(RestTemplate.class);
|
||||||
|
reply(http, LATEST, "{\"tag_name\":\"v1.6.0\",\"html_url\":\"https://x/1.6.0\"}");
|
||||||
|
|
||||||
|
Optional<DesktopUpdateService.UpdateInfo> info = service("1.5.0", http).checkForUpdate();
|
||||||
|
|
||||||
|
assertTrue(info.isPresent());
|
||||||
|
assertEquals("1.6.0", info.get().latestVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void betaVersion_isToldAboutTheNextBeta() throws Exception {
|
||||||
|
RestTemplate http = mock(RestTemplate.class);
|
||||||
|
reply(http, ALL, "[{\"tag_name\":\"v1.5.0-beta.2\",\"prerelease\":true,\"html_url\":\"https://x/b2\"},"
|
||||||
|
+ "{\"tag_name\":\"v1.6.0-beta\",\"draft\":true},"
|
||||||
|
+ "{\"tag_name\":\"v1.4.0\",\"html_url\":\"https://x/1.4.0\"}]");
|
||||||
|
|
||||||
|
Optional<DesktopUpdateService.UpdateInfo> info = service("1.5.0-beta", http).checkForUpdate();
|
||||||
|
|
||||||
|
assertTrue(info.isPresent(), "beta.2 > beta ; le brouillon 1.6.0-beta est ignore");
|
||||||
|
assertEquals("1.5.0-beta.2", info.get().latestVersion());
|
||||||
|
assertEquals("https://x/b2", info.get().releaseUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void betaVersion_isToldWhenTheStableReleaseReplacesIt() throws Exception {
|
||||||
|
RestTemplate http = mock(RestTemplate.class);
|
||||||
|
reply(http, ALL, "[{\"tag_name\":\"v1.5.0\",\"html_url\":\"https://x/1.5.0\"},"
|
||||||
|
+ "{\"tag_name\":\"v1.5.0-beta\",\"prerelease\":true}]");
|
||||||
|
|
||||||
|
Optional<DesktopUpdateService.UpdateInfo> info = service("1.5.0-beta", http).checkForUpdate();
|
||||||
|
|
||||||
|
assertTrue(info.isPresent());
|
||||||
|
assertEquals("1.5.0", info.get().latestVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void betaVersion_upToDate() throws Exception {
|
||||||
|
RestTemplate http = mock(RestTemplate.class);
|
||||||
|
reply(http, ALL, "[{\"tag_name\":\"v1.5.0-beta\",\"prerelease\":true},{\"tag_name\":\"v1.4.0\"}]");
|
||||||
|
|
||||||
|
assertFalse(service("1.5.0-beta", http).checkForUpdate().isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void compareVersions_ordersStableAfterBetaAndBetasByNumber() {
|
||||||
|
assertTrue(DesktopUpdateService.compareVersions("1.5.0-beta", "1.5.0") < 0);
|
||||||
|
assertTrue(DesktopUpdateService.compareVersions("1.5.0-beta", "1.5.0-beta.2") < 0);
|
||||||
|
assertTrue(DesktopUpdateService.compareVersions("1.5.0-beta.2", "1.5.0-beta.10") < 0);
|
||||||
|
assertTrue(DesktopUpdateService.compareVersions("1.6.0-beta", "1.5.0") > 0);
|
||||||
|
assertEquals(0, DesktopUpdateService.compareVersions("1.5.0", "1.5.0"));
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package com.loremind.infrastructure.updates;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class LegacyRegistryCredentialsCleanupTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void removesTheOldGhcrCredentials(@TempDir Path dir) throws Exception {
|
||||||
|
Path config = dir.resolve("config.json");
|
||||||
|
Files.writeString(config, "{\"auths\":{\"ghcr.io\":{\"auth\":\"dXNlcjpwYXQ=\"}}}");
|
||||||
|
|
||||||
|
assertTrue(new LegacyRegistryCredentialsCleanup(config.toString()).cleanup());
|
||||||
|
assertFalse(Files.exists(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void doesNothingOnRecentInstalls(@TempDir Path dir) {
|
||||||
|
assertFalse(new LegacyRegistryCredentialsCleanup("").cleanup());
|
||||||
|
assertFalse(new LegacyRegistryCredentialsCleanup(dir.resolve("config.json").toString()).cleanup());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.loremind.infrastructure.updates;
|
package com.loremind.infrastructure.updates;
|
||||||
|
|
||||||
|
import com.loremind.application.channel.ChannelSwitcherService;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatus;
|
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatus;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatusKind;
|
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatusKind;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.TagsListResponse;
|
import com.loremind.infrastructure.updates.UpdateCheckService.TagsListResponse;
|
||||||
@@ -7,6 +8,9 @@ import com.loremind.infrastructure.updates.UpdateCheckService.UpdateStatus;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.info.BuildProperties;
|
import org.springframework.boot.info.BuildProperties;
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -41,20 +45,64 @@ class UpdateCheckServiceTest {
|
|||||||
p.setProperty("version", currentVersion);
|
p.setProperty("version", currentVersion);
|
||||||
bp = new BuildProperties(p);
|
bp = new BuildProperties(p);
|
||||||
}
|
}
|
||||||
// licenseService null : la beta est testee separement, ces tests
|
return newService(token, bp, ChannelSwitcherService.Channel.STABLE);
|
||||||
// couvrent uniquement le canal stable.
|
}
|
||||||
|
|
||||||
|
private static UpdateCheckService newService(String token, BuildProperties bp,
|
||||||
|
ChannelSwitcherService.Channel channel) {
|
||||||
|
ChannelSwitcherService channels = mock(ChannelSwitcherService.class);
|
||||||
|
when(channels.getCurrentChannel()).thenReturn(channel);
|
||||||
return new UpdateCheckService(
|
return new UpdateCheckService(
|
||||||
new RestTemplateBuilder(),
|
new RestTemplateBuilder(),
|
||||||
"ghcr.io",
|
"ghcr.io",
|
||||||
"igmlcreation/loremind-core,igmlcreation/loremind-brain",
|
"igmlcreation/loremind-core,igmlcreation/loremind-brain",
|
||||||
"http://watchtower:8080",
|
"http://watchtower:8080",
|
||||||
token,
|
token,
|
||||||
"",
|
"ghcr.io",
|
||||||
null,
|
"igmlcreation/loremind-beta-core",
|
||||||
|
channels,
|
||||||
bp
|
bp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BuildProperties version(String v) {
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.setProperty("version", v);
|
||||||
|
return new BuildProperties(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Canal beta (libre : images publiques, lecture anonyme) ------------------
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void checkBeta_disabledWhenNotOnBetaChannel() {
|
||||||
|
UpdateCheckService svc = newService("tok", version("1.4.0"), ChannelSwitcherService.Channel.STABLE);
|
||||||
|
RestTemplate http = stubHttp(svc);
|
||||||
|
|
||||||
|
UpdateCheckService.BetaStatus status = svc.checkBeta();
|
||||||
|
|
||||||
|
assertFalse(status.enabled());
|
||||||
|
assertEquals("not-on-beta-channel", status.disabledReason());
|
||||||
|
verifyNoInteractions(http);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void checkBeta_readsPublicBetaImagesWithoutCredentials() {
|
||||||
|
UpdateCheckService svc = newService("tok", version("1.5.0-beta"), ChannelSwitcherService.Channel.BETA);
|
||||||
|
RestTemplate http = stubHttp(svc);
|
||||||
|
stubTags(http, "igmlcreation/loremind-beta-core", List.of("beta", "1.5.0-beta", "1.6.0-beta"));
|
||||||
|
|
||||||
|
UpdateCheckService.BetaStatus status = svc.checkBeta();
|
||||||
|
|
||||||
|
assertTrue(status.enabled());
|
||||||
|
assertTrue(status.updateAvailable());
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ArgumentCaptor<HttpEntity> sent = ArgumentCaptor.forClass(HttpEntity.class);
|
||||||
|
verify(http).exchange(eq("https://ghcr.io/v2/igmlcreation/loremind-beta-core/tags/list"),
|
||||||
|
eq(HttpMethod.GET), sent.capture(), eq(TagsListResponse.class));
|
||||||
|
assertFalse(sent.getValue().getHeaders().containsKey(HttpHeaders.AUTHORIZATION),
|
||||||
|
"plus d'identifiants : les images beta sont publiques");
|
||||||
|
}
|
||||||
|
|
||||||
private static RestTemplate stubHttp(UpdateCheckService svc) {
|
private static RestTemplate stubHttp(UpdateCheckService svc) {
|
||||||
RestTemplate http = mock(RestTemplate.class);
|
RestTemplate http = mock(RestTemplate.class);
|
||||||
ReflectionTestUtils.setField(svc, "http", http);
|
ReflectionTestUtils.setField(svc, "http", http);
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ class RemoteAccessFilterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lan_adminRoutes_areAlwaysForbidden_evenWhenPaired() throws Exception {
|
void lan_adminRoutes_areAlwaysForbidden_evenWhenPaired() throws Exception {
|
||||||
for (String path : new String[]{"/api/settings", "/api/settings/remote-access", "/api/admin/data/export", "/api/license"}) {
|
for (String path : new String[]{"/api/settings", "/api/settings/remote-access", "/api/admin/data/export", "/api/admin/updates/channel"}) {
|
||||||
Outcome outcome = run(LAN_PORT, path, "bon-jeton");
|
Outcome outcome = run(LAN_PORT, path, "bon-jeton");
|
||||||
assertFalse(outcome.passed(), path);
|
assertFalse(outcome.passed(), path);
|
||||||
assertEquals(403, outcome.status(), path);
|
assertEquals(403, outcome.status(), path);
|
||||||
|
|||||||
-263
@@ -1,263 +0,0 @@
|
|||||||
package com.loremind.infrastructure.web.controller;
|
|
||||||
|
|
||||||
import com.loremind.application.licensing.ChannelSwitcherService;
|
|
||||||
import com.loremind.application.licensing.LicenseService;
|
|
||||||
import com.loremind.application.licensing.LicenseService.InstallException;
|
|
||||||
import com.loremind.domain.licensing.LicenseSnapshot;
|
|
||||||
import com.loremind.domain.licensing.LicenseStatus;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
||||||
import static org.mockito.Mockito.doThrow;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests d'integration pour {@link LicenseController} (gestion licence Patreon).
|
|
||||||
* <p>
|
|
||||||
* {@code /api/license/**} exige le role ADMIN (HTTP Basic) : chaque requete porte
|
|
||||||
* l'entete d'auth construite a partir des identifiants de test (cf.
|
|
||||||
* src/test/resources/application.properties). Sans cet entete, la securite
|
|
||||||
* renverrait 401.
|
|
||||||
* <p>
|
|
||||||
* Les deux services applicatifs sont mockes : {@link LicenseService} (qui appelle
|
|
||||||
* sinon le relais OAuth distant + verification JWT) et {@link ChannelSwitcherService}
|
|
||||||
* (qui ecrit sinon dans un volume partage avec le sidecar). Aucun acces reseau ni
|
|
||||||
* fichier reel.
|
|
||||||
*/
|
|
||||||
@SpringBootTest
|
|
||||||
@AutoConfigureMockMvc
|
|
||||||
class LicenseControllerTest {
|
|
||||||
|
|
||||||
/** Identifiants definis dans src/test/resources/application.properties. */
|
|
||||||
private static final String ADMIN_AUTH = "Basic " + Base64.getEncoder()
|
|
||||||
.encodeToString("test-admin:test-admin-password".getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
/** Horodatage fixe : la valeur exacte n'importe pas, seule la sérialisation JSON est testée. */
|
|
||||||
private static final Instant FIXED_NOW = Instant.parse("2026-01-01T12:00:00Z");
|
|
||||||
|
|
||||||
@Autowired private MockMvc mockMvc;
|
|
||||||
|
|
||||||
@MockitoBean private LicenseService licenseService;
|
|
||||||
@MockitoBean private ChannelSwitcherService channelSwitcher;
|
|
||||||
|
|
||||||
private LicenseSnapshot validSnapshot() {
|
|
||||||
return new LicenseSnapshot(
|
|
||||||
LicenseStatus.VALID, "user-42", "tier-1", "li-xyz",
|
|
||||||
FIXED_NOW.plusSeconds(3600), FIXED_NOW, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
// Valeurs par defaut neutres ; chaque test surcharge ce dont il a besoin.
|
|
||||||
when(licenseService.isLicensingEnabled()).thenReturn(true);
|
|
||||||
when(licenseService.getCurrentSnapshot()).thenReturn(validSnapshot());
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Securite ----------------------------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getStatus_returns401_withoutAuth() throws Exception {
|
|
||||||
mockMvc.perform(get("/api/license"))
|
|
||||||
.andExpect(status().isUnauthorized());
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- GET /api/license --------------------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getStatus_returns200() throws Exception {
|
|
||||||
mockMvc.perform(get("/api/license").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.enabled").value(true))
|
|
||||||
.andExpect(jsonPath("$.status").value("VALID"))
|
|
||||||
.andExpect(jsonPath("$.patreonUserId").value("user-42"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- GET /api/license/connect-url --------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getConnectUrl_returns200() throws Exception {
|
|
||||||
when(licenseService.buildConnectUrl()).thenReturn("https://relay/oauth?x=1");
|
|
||||||
mockMvc.perform(get("/api/license/connect-url").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.url").value("https://relay/oauth?x=1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- POST /api/license/install -----------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void install_returns200_onValidJwt() throws Exception {
|
|
||||||
when(licenseService.installToken("good-jwt")).thenReturn(validSnapshot());
|
|
||||||
mockMvc.perform(post("/api/license/install")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"jwt\":\"good-jwt\"}"))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.status").value("VALID"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void install_returns400_whenJwtMissing() throws Exception {
|
|
||||||
mockMvc.perform(post("/api/license/install")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"jwt\":\"\"}"))
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andExpect(jsonPath("$.error").value("missing jwt"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void install_returns400_whenInstallFails() throws Exception {
|
|
||||||
when(licenseService.installToken("bad-jwt"))
|
|
||||||
.thenThrow(new InstallException("Invalid JWT: signature"));
|
|
||||||
mockMvc.perform(post("/api/license/install")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"jwt\":\"bad-jwt\"}"))
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andExpect(jsonPath("$.error").value("Invalid JWT: signature"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- DELETE /api/license -----------------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void disconnect_returns204() throws Exception {
|
|
||||||
mockMvc.perform(delete("/api/license").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
|
||||||
.andExpect(status().isNoContent());
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- POST /api/license/refresh -----------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void refresh_returns200() throws Exception {
|
|
||||||
mockMvc.perform(post("/api/license/refresh").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.status").value("VALID"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- PUT /api/license/beta-channel -------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setBetaChannel_returns200() throws Exception {
|
|
||||||
when(licenseService.setBetaChannelEnabled(false)).thenReturn(validSnapshot());
|
|
||||||
mockMvc.perform(put("/api/license/beta-channel")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"enabled\":false}"))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.status").value("VALID"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setBetaChannel_returns409_whenNoLicense() throws Exception {
|
|
||||||
when(licenseService.setBetaChannelEnabled(anyBoolean()))
|
|
||||||
.thenThrow(new IllegalStateException("No license installed"));
|
|
||||||
mockMvc.perform(put("/api/license/beta-channel")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"enabled\":true}"))
|
|
||||||
.andExpect(status().isConflict())
|
|
||||||
.andExpect(jsonPath("$.error").value("No license installed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- GET /api/license/channel ------------------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getChannel_returns200() throws Exception {
|
|
||||||
when(channelSwitcher.getCurrentChannel()).thenReturn(ChannelSwitcherService.Channel.STABLE);
|
|
||||||
when(channelSwitcher.isSwitcherAvailable()).thenReturn(true);
|
|
||||||
when(channelSwitcher.getLastResult()).thenReturn(null);
|
|
||||||
mockMvc.perform(get("/api/license/channel").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath("$.currentChannel").value("stable"))
|
|
||||||
.andExpect(jsonPath("$.switcherAvailable").value(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- POST /api/license/channel/switch ----------------------------------
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns400_whenChannelMissing() throws Exception {
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{}"))
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andExpect(jsonPath("$.error").value("missing channel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns400_whenChannelInvalid() throws Exception {
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"channel\":\"nightly\"}"))
|
|
||||||
.andExpect(status().isBadRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns403_whenBetaWithoutLicense() throws Exception {
|
|
||||||
// Snapshot EXPIRED -> pas d'acces beta.
|
|
||||||
when(licenseService.getCurrentSnapshot()).thenReturn(new LicenseSnapshot(
|
|
||||||
LicenseStatus.EXPIRED, null, null, null, null, null, false, false));
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"channel\":\"beta\"}"))
|
|
||||||
.andExpect(status().isForbidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns503_whenSwitcherUnavailable() throws Exception {
|
|
||||||
// Licence VALID (autorise beta) mais sidecar absent.
|
|
||||||
when(channelSwitcher.isSwitcherAvailable()).thenReturn(false);
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"channel\":\"beta\"}"))
|
|
||||||
.andExpect(status().isServiceUnavailable());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns202_onSuccess() throws Exception {
|
|
||||||
when(channelSwitcher.isSwitcherAvailable()).thenReturn(true);
|
|
||||||
when(channelSwitcher.requestSwitch(ChannelSwitcherService.Channel.STABLE))
|
|
||||||
.thenReturn("cmd-1");
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"channel\":\"stable\"}"))
|
|
||||||
.andExpect(status().isAccepted())
|
|
||||||
.andExpect(jsonPath("$.id").value("cmd-1"))
|
|
||||||
.andExpect(jsonPath("$.channel").value("stable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void switchChannel_returns500_whenWriteFails() throws Exception {
|
|
||||||
when(channelSwitcher.isSwitcherAvailable()).thenReturn(true);
|
|
||||||
doThrow(new IOException("disk full"))
|
|
||||||
.when(channelSwitcher).requestSwitch(ChannelSwitcherService.Channel.STABLE);
|
|
||||||
mockMvc.perform(post("/api/license/channel/switch")
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"channel\":\"stable\"}"))
|
|
||||||
.andExpect(status().isInternalServerError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+48
@@ -1,5 +1,6 @@
|
|||||||
package com.loremind.infrastructure.web.controller;
|
package com.loremind.infrastructure.web.controller;
|
||||||
|
|
||||||
|
import com.loremind.application.channel.ChannelSwitcherService;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService;
|
import com.loremind.infrastructure.updates.UpdateCheckService;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.BetaStatus;
|
import com.loremind.infrastructure.updates.UpdateCheckService.BetaStatus;
|
||||||
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatus;
|
import com.loremind.infrastructure.updates.UpdateCheckService.ImageStatus;
|
||||||
@@ -11,6 +12,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -45,6 +47,7 @@ class UpdatesControllerTest {
|
|||||||
|
|
||||||
@Autowired private MockMvc mockMvc;
|
@Autowired private MockMvc mockMvc;
|
||||||
@MockitoBean private UpdateCheckService updates;
|
@MockitoBean private UpdateCheckService updates;
|
||||||
|
@MockitoBean private ChannelSwitcherService channels;
|
||||||
|
|
||||||
private UpdateStatus sampleUpdate() {
|
private UpdateStatus sampleUpdate() {
|
||||||
return new UpdateStatus(true, true, false, "1.0.0",
|
return new UpdateStatus(true, true, false, "1.0.0",
|
||||||
@@ -56,6 +59,51 @@ class UpdatesControllerTest {
|
|||||||
return new BetaStatus(true, false, false, List.of(), FIXED_INSTANT, null);
|
return new BetaStatus(true, false, false, List.of(), FIXED_INSTANT, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Canal beta libre : bascule sans licence -------------------------------
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void switchToBeta_isAcceptedWithoutAnyLicense() throws Exception {
|
||||||
|
when(channels.isSwitcherAvailable()).thenReturn(true);
|
||||||
|
when(channels.requestSwitch(ChannelSwitcherService.Channel.BETA))
|
||||||
|
.thenReturn("cmd-1");
|
||||||
|
mockMvc.perform(post("/api/admin/updates/channel/switch")
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content("{\"channel\":\"beta\"}"))
|
||||||
|
.andExpect(status().isAccepted())
|
||||||
|
.andExpect(jsonPath("$.id").value("cmd-1"))
|
||||||
|
.andExpect(jsonPath("$.channel").value("beta"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void switchChannel_rejectsUnknownChannel() throws Exception {
|
||||||
|
mockMvc.perform(post("/api/admin/updates/channel/switch")
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content("{\"channel\":\"nightly\"}"))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void switchChannel_503WhenSwitcherMissing() throws Exception {
|
||||||
|
when(channels.isSwitcherAvailable()).thenReturn(false);
|
||||||
|
mockMvc.perform(post("/api/admin/updates/channel/switch")
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content("{\"channel\":\"beta\"}"))
|
||||||
|
.andExpect(status().isServiceUnavailable());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void channel_returnsCurrentChannel() throws Exception {
|
||||||
|
when(channels.getCurrentChannel()).thenReturn(ChannelSwitcherService.Channel.BETA);
|
||||||
|
when(channels.isSwitcherAvailable()).thenReturn(true);
|
||||||
|
mockMvc.perform(get("/api/admin/updates/channel").header(HttpHeaders.AUTHORIZATION, ADMIN_AUTH))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.currentChannel").value("beta"))
|
||||||
|
.andExpect(jsonPath("$.switcherAvailable").value(true));
|
||||||
|
}
|
||||||
|
|
||||||
// --- GET /check ---------------------------------------------------------
|
// --- GET /check ---------------------------------------------------------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ minio.bucket=test-bucket
|
|||||||
# open-in-view fixe explicitement (defaut true) : supprime l'avertissement au boot.
|
# open-in-view fixe explicitement (defaut true) : supprime l'avertissement au boot.
|
||||||
spring.jpa.open-in-view=true
|
spring.jpa.open-in-view=true
|
||||||
|
|
||||||
# Le daemon de refresh de licence (@Scheduled) n'a rien a faire pendant les tests :
|
|
||||||
# son tick echouait en arriere-plan (table licenses droppee par le create-drop
|
|
||||||
# partage entre contextes) => stacktraces parasites. On le desactive ici.
|
|
||||||
licensing.refresh.enabled=false
|
|
||||||
|
|
||||||
# --- Sortie de test LISIBLE ---------------------------------------------------
|
# --- Sortie de test LISIBLE ---------------------------------------------------
|
||||||
# Pas de banniere Spring (repetee a chaque contexte), et seuls les WARN/ERROR
|
# Pas de banniere Spring (repetee a chaque contexte), et seuls les WARN/ERROR
|
||||||
# remontent : la masse d'INFO de demarrage (Spring/Hibernate/Hikari, "Started
|
# remontent : la masse d'INFO de demarrage (Spring/Hibernate/Hikari, "Started
|
||||||
|
|||||||
@@ -94,22 +94,10 @@ services:
|
|||||||
UPDATE_CHECK_TAG: ${TAG:-latest}
|
UPDATE_CHECK_TAG: ${TAG:-latest}
|
||||||
WATCHTOWER_URL: http://watchtower:8080
|
WATCHTOWER_URL: http://watchtower:8080
|
||||||
WATCHTOWER_TOKEN: ${WATCHTOWER_TOKEN:-}
|
WATCHTOWER_TOKEN: ${WATCHTOWER_TOKEN:-}
|
||||||
# Licensing : la cle publique JWT est embarquee dans le binaire
|
|
||||||
# (core/src/main/resources/licensing/jwt-public-key.pem).
|
|
||||||
# LICENSING_JWT_PUBLIC_KEY est un override optionnel (rotation de cle
|
|
||||||
# sans rebuild) - non defini par defaut.
|
|
||||||
LICENSING_JWT_PUBLIC_KEY: ${LICENSING_JWT_PUBLIC_KEY:-}
|
|
||||||
LICENSING_RELAY_BASE_URL: ${LICENSING_RELAY_BASE_URL:-https://loremind-auth.igmlcreation.fr}
|
|
||||||
# Chemin du docker config.json partage avec Watchtower
|
|
||||||
LICENSING_DOCKER_CONFIG_PATH: /shared/docker/config.json
|
|
||||||
# Chemin du repertoire partage avec le switcher (commande + resultat).
|
# Chemin du repertoire partage avec le switcher (commande + resultat).
|
||||||
# Doit matcher le volume `switcher-data` monte ci-dessous.
|
# Doit matcher le volume `switcher-data` monte ci-dessous.
|
||||||
SWITCHER_DATA_PATH: /shared/switcher
|
SWITCHER_DATA_PATH: /shared/switcher
|
||||||
volumes:
|
volumes:
|
||||||
# Volume partage avec Watchtower : Core ecrit les credentials registry
|
|
||||||
# GHCR (recus du relais) ici, Watchtower les utilise pour pull les images
|
|
||||||
# privees du canal beta. Pas de creds = no-op.
|
|
||||||
- docker-config:/shared/docker
|
|
||||||
# Volume partage avec le switcher : Core ecrit une commande de switch
|
# Volume partage avec le switcher : Core ecrit une commande de switch
|
||||||
# de canal ici (command.json), le switcher la traite et y depose son
|
# de canal ici (command.json), le switcher la traite et y depose son
|
||||||
# resultat (result.json). Cf. service `switcher` ci-dessous.
|
# resultat (result.json). Cf. service `switcher` ci-dessous.
|
||||||
@@ -202,10 +190,6 @@ services:
|
|||||||
- ${COMPOSE_PROJECT_DIR:-./}:/compose
|
- ${COMPOSE_PROJECT_DIR:-./}:/compose
|
||||||
# Volume partage avec le Core pour la commande + le resultat.
|
# Volume partage avec le Core pour la commande + le resultat.
|
||||||
- switcher-data:/data
|
- switcher-data:/data
|
||||||
# Volume partage avec le Core + Watchtower : contient config.json avec
|
|
||||||
# les creds GHCR (ecrits par le Core a partir du token Patreon).
|
|
||||||
# Indispensable pour pull les images privees du canal beta.
|
|
||||||
- docker-config:/shared/docker
|
|
||||||
environment:
|
environment:
|
||||||
# Repertoire interne ou trouver docker-compose.yml et .env. Bind au
|
# Repertoire interne ou trouver docker-compose.yml et .env. Bind au
|
||||||
# volume ci-dessus (COMPOSE_PROJECT_DIR = repertoire d'install du host).
|
# volume ci-dessus (COMPOSE_PROJECT_DIR = repertoire d'install du host).
|
||||||
@@ -214,9 +198,6 @@ services:
|
|||||||
# le MEME stack que celui qui tourne (sinon il creerait un duplicate).
|
# le MEME stack que celui qui tourne (sinon il creerait un duplicate).
|
||||||
# Doit matcher le `name:` (en V2.x) ou le nom du dossier du host.
|
# Doit matcher le `name:` (en V2.x) ou le nom du dossier du host.
|
||||||
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME:-loremind}
|
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME:-loremind}
|
||||||
# Indique au CLI Docker du switcher ou trouver config.json (auth GHCR
|
|
||||||
# pour les images privees beta). Meme mecanisme que sur Watchtower.
|
|
||||||
DOCKER_CONFIG: /shared/docker
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Mises a jour automatiques des images core/brain/web.
|
# Mises a jour automatiques des images core/brain/web.
|
||||||
@@ -234,14 +215,7 @@ services:
|
|||||||
profiles: ["autoupdate"]
|
profiles: ["autoupdate"]
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
# Volume partage avec Core : credentials registry GHCR (canal beta).
|
|
||||||
# Watchtower lit le config.json depuis DOCKER_CONFIG.
|
|
||||||
- docker-config:/shared/docker
|
|
||||||
environment:
|
environment:
|
||||||
# Indique a Watchtower (et au CLI Docker embarque) ou trouver le
|
|
||||||
# config.json. Active automatiquement l'auth GHCR pour les images
|
|
||||||
# du canal beta des que Core a ecrit le fichier.
|
|
||||||
DOCKER_CONFIG: /shared/docker
|
|
||||||
WATCHTOWER_LABEL_ENABLE: "true"
|
WATCHTOWER_LABEL_ENABLE: "true"
|
||||||
WATCHTOWER_CLEANUP: "true"
|
WATCHTOWER_CLEANUP: "true"
|
||||||
WATCHTOWER_INCLUDE_RESTARTING: "true"
|
WATCHTOWER_INCLUDE_RESTARTING: "true"
|
||||||
@@ -267,8 +241,5 @@ volumes:
|
|||||||
minio-data:
|
minio-data:
|
||||||
brain-data:
|
brain-data:
|
||||||
ollama-data:
|
ollama-data:
|
||||||
# Volume partage Core <-> Watchtower : config.json Docker pour
|
|
||||||
# l'authentification au registry prive GHCR (canal beta Patreon).
|
|
||||||
docker-config:
|
|
||||||
# Volume partage Core <-> Switcher : commande de bascule de canal + resultat.
|
# Volume partage Core <-> Switcher : commande de bascule de canal + resultat.
|
||||||
switcher-data:
|
switcher-data:
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Observable, catchError, map, of } from 'rxjs';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reflet de LicenseStatus (enum cote backend).
|
|
||||||
*/
|
|
||||||
export type LicenseStatus = 'NONE' | 'VALID' | 'GRACE' | 'EXPIRED' | 'UNVERIFIABLE';
|
|
||||||
|
|
||||||
export interface LicenseStatusDTO {
|
|
||||||
enabled: boolean;
|
|
||||||
status: LicenseStatus;
|
|
||||||
patreonUserId: string | null;
|
|
||||||
tierId: string | null;
|
|
||||||
instanceId: string | null;
|
|
||||||
expiresAt: string | null;
|
|
||||||
lastRefreshAttemptAt: string | null;
|
|
||||||
lastRefreshSucceeded: boolean | null;
|
|
||||||
betaChannelEnabled: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Etat du canal courant + dernier resultat de bascule (cf. ChannelStatusDTO cote backend).
|
|
||||||
*/
|
|
||||||
export type ChannelName = 'stable' | 'beta';
|
|
||||||
export type SwitchStatus = 'IN_PROGRESS' | 'SUCCESS' | 'ERROR';
|
|
||||||
|
|
||||||
export interface ChannelStatusDTO {
|
|
||||||
currentChannel: ChannelName;
|
|
||||||
switcherAvailable: boolean;
|
|
||||||
lastSwitch: {
|
|
||||||
id: string;
|
|
||||||
status: SwitchStatus;
|
|
||||||
channel: ChannelName;
|
|
||||||
message: string;
|
|
||||||
completedAt: string;
|
|
||||||
} | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reflet de UpdateCheckService.BetaStatus.
|
|
||||||
*/
|
|
||||||
export interface BetaStatusDTO {
|
|
||||||
enabled: boolean;
|
|
||||||
updateAvailable: boolean;
|
|
||||||
anyUnknown: boolean;
|
|
||||||
images: {
|
|
||||||
image: string;
|
|
||||||
localVersion: string | null;
|
|
||||||
remoteVersion: string | null;
|
|
||||||
status: 'UP_TO_DATE' | 'UPDATE_AVAILABLE' | 'UNKNOWN';
|
|
||||||
updateAvailable: boolean;
|
|
||||||
}[];
|
|
||||||
checkedAt: string;
|
|
||||||
disabledReason: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service Angular pour la gestion de la licence Patreon.
|
|
||||||
* Tous les endpoints sont proteges par HTTP Basic (admin).
|
|
||||||
*/
|
|
||||||
@Injectable({ providedIn: 'root' })
|
|
||||||
export class LicenseService {
|
|
||||||
private readonly apiUrl = '/api/license';
|
|
||||||
private readonly authOptions = { withCredentials: true };
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
|
||||||
|
|
||||||
getStatus(): Observable<LicenseStatusDTO | null> {
|
|
||||||
return this.http.get<LicenseStatusDTO>(this.apiUrl, this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getConnectUrl(): Observable<{ url: string } | null> {
|
|
||||||
return this.http.get<{ url: string }>(`${this.apiUrl}/connect-url`, this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
install(jwt: string): Observable<LicenseStatusDTO | { error: string }> {
|
|
||||||
return this.http.post<LicenseStatusDTO>(`${this.apiUrl}/install`, { jwt }, this.authOptions).pipe(
|
|
||||||
catchError((err) => of({ error: err?.error?.error ?? 'Echec de l\'installation' }))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnect(): Observable<boolean> {
|
|
||||||
return this.http.delete<void>(this.apiUrl, this.authOptions).pipe(
|
|
||||||
// Convertit en boolean : true = succes, false = erreur.
|
|
||||||
// (Avant : le cast `as unknown as` masquait l'absence de map() — le
|
|
||||||
// succes emettait `undefined`, donc falsy. Consommateur actuel ignore
|
|
||||||
// la valeur, mais le type est desormais honnete.)
|
|
||||||
map(() => true),
|
|
||||||
catchError(() => of(false))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh(): Observable<LicenseStatusDTO | null> {
|
|
||||||
return this.http.post<LicenseStatusDTO>(`${this.apiUrl}/refresh`, null, this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setBetaChannel(enabled: boolean): Observable<LicenseStatusDTO | null> {
|
|
||||||
return this.http.put<LicenseStatusDTO>(`${this.apiUrl}/beta-channel`, { enabled }, this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkBeta(): Observable<BetaStatusDTO | null> {
|
|
||||||
return this.http.get<BetaStatusDTO>('/api/admin/updates/check-beta', this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Etat du canal courant et dernier resultat de switch (pour polling UI). */
|
|
||||||
getChannelStatus(): Observable<ChannelStatusDTO | null> {
|
|
||||||
return this.http.get<ChannelStatusDTO>(`${this.apiUrl}/channel`, this.authOptions).pipe(
|
|
||||||
catchError(() => of(null))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Declenche un switch de canal. 202 + { id, channel } si accepte,
|
|
||||||
* sinon erreur (403 = pas de licence, 503 = sidecar indispo, etc.).
|
|
||||||
*/
|
|
||||||
switchChannel(channel: ChannelName): Observable<{ id: string; channel: ChannelName } | { error: string }> {
|
|
||||||
return this.http.post<{ id: string; channel: ChannelName }>(
|
|
||||||
`${this.apiUrl}/channel/switch`, { channel }, this.authOptions
|
|
||||||
).pipe(
|
|
||||||
catchError((err) => of({ error: err?.error?.error ?? 'Echec du switch de canal' }))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,6 +32,32 @@ export interface UpdateStatus {
|
|||||||
checkedAt: string;
|
checkedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Canal courant + dernier resultat de bascule (cf. ChannelStatusDTO cote backend). */
|
||||||
|
export type ChannelName = 'stable' | 'beta';
|
||||||
|
export type SwitchStatus = 'IN_PROGRESS' | 'SUCCESS' | 'ERROR';
|
||||||
|
|
||||||
|
export interface ChannelStatusDTO {
|
||||||
|
currentChannel: ChannelName;
|
||||||
|
switcherAvailable: boolean;
|
||||||
|
lastSwitch: {
|
||||||
|
id: string;
|
||||||
|
status: SwitchStatus;
|
||||||
|
channel: ChannelName;
|
||||||
|
message: string;
|
||||||
|
completedAt: string;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reflet de UpdateCheckService.BetaStatus (images beta publiques, verifiees en beta). */
|
||||||
|
export interface BetaStatusDTO {
|
||||||
|
enabled: boolean;
|
||||||
|
updateAvailable: boolean;
|
||||||
|
anyUnknown: boolean;
|
||||||
|
images: ImageStatus[];
|
||||||
|
checkedAt: string;
|
||||||
|
disabledReason: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service de detection / declenchement des mises a jour des conteneurs
|
* Service de detection / declenchement des mises a jour des conteneurs
|
||||||
* LoreMind. Endpoints proteges par HTTP Basic (admin) — withCredentials
|
* LoreMind. Endpoints proteges par HTTP Basic (admin) — withCredentials
|
||||||
@@ -72,4 +98,27 @@ export class UpdatesService {
|
|||||||
catchError(() => of(null))
|
catchError(() => of(null))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Nouvelle beta disponible ? (seulement quand l'instance tourne sur le canal beta). */
|
||||||
|
checkBeta(): Observable<BetaStatusDTO | null> {
|
||||||
|
return this.http.get<BetaStatusDTO>(`${this.apiUrl}/check-beta`, this.authOptions).pipe(
|
||||||
|
catchError(() => of(null))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Canal courant et dernier resultat de bascule (pour le polling de l'UI). */
|
||||||
|
getChannelStatus(): Observable<ChannelStatusDTO | null> {
|
||||||
|
return this.http.get<ChannelStatusDTO>(`${this.apiUrl}/channel`, this.authOptions).pipe(
|
||||||
|
catchError(() => of(null))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Demande une bascule de canal : 202 + { id, channel }, sinon { error } (503 = sidecar absent…). */
|
||||||
|
switchChannel(channel: ChannelName): Observable<{ id: string; channel: ChannelName } | { error: string }> {
|
||||||
|
return this.http.post<{ id: string; channel: ChannelName }>(
|
||||||
|
`${this.apiUrl}/channel/switch`, { channel }, this.authOptions
|
||||||
|
).pipe(
|
||||||
|
catchError((err) => of({ error: err?.error?.error ?? 'Echec du switch de canal' }))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,7 +379,7 @@
|
|||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!-- Mises a jour conteneurs + licence Patreon + canal beta (sous-composant) -->
|
<!-- Mises a jour conteneurs + canal beta (sous-composant) -->
|
||||||
<app-settings-updates-section></app-settings-updates-section>
|
<app-settings-updates-section></app-settings-updates-section>
|
||||||
|
|
||||||
<!-- Sauvegarde / Restauration des donnees (export & import) -->
|
<!-- Sauvegarde / Restauration des donnees (export & import) -->
|
||||||
|
|||||||
@@ -456,53 +456,7 @@
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Section Patreon / canal beta ---------------------------------------
|
// --- Canal beta -----------------------------------------------------------
|
||||||
.license-info {
|
|
||||||
list-style: none;
|
|
||||||
margin: 12px 0 16px;
|
|
||||||
padding: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 6px;
|
|
||||||
|
|
||||||
li {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
padding: 6px 10px;
|
|
||||||
background: rgba(255, 255, 255, 0.03);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
||||||
border-radius: 4px;
|
|
||||||
|
|
||||||
strong {
|
|
||||||
color: #c4b8e0;
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-row-inline {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-row-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 12px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary.btn-danger {
|
|
||||||
border-color: rgba(220, 80, 80, 0.4);
|
|
||||||
color: #ff7878;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(220, 80, 80, 0.12);
|
|
||||||
border-color: rgba(220, 80, 80, 0.6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.beta-status {
|
.beta-status {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { RemoteAccessService } from '../services/remote-access.service';
|
|||||||
* cles API, embeddings RAG, fenetre de contexte, import PDF) + sa sauvegarde.
|
* cles API, embeddings RAG, fenetre de contexte, import PDF) + sa sauvegarde.
|
||||||
*
|
*
|
||||||
* Les responsabilites voisines sont des sous-composants standalone :
|
* Les responsabilites voisines sont des sous-composants standalone :
|
||||||
* - UpdatesSectionComponent : mises a jour conteneurs + licence Patreon + canal beta ;
|
* - UpdatesSectionComponent : mises a jour conteneurs + canal beta ;
|
||||||
* - OllamaModelManagerComponent : pull/suppression des modeles Ollama.
|
* - OllamaModelManagerComponent : pull/suppression des modeles Ollama.
|
||||||
*
|
*
|
||||||
* Les modifications sont persistees cote Brain dans data/settings.json
|
* Les modifications sont persistees cote Brain dans data/settings.json
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
<!-- Bloc Mises a jour (canal stable + canal beta Patreon fusionnes) -->
|
<!-- Bloc Mises a jour (canal stable + canal beta) : Docker uniquement. En mode bureau,
|
||||||
@if (config.updateCheckEnabled || licenseStatus?.enabled) {
|
ni Watchtower ni sidecar switcher : la section reste masquee. -->
|
||||||
|
@if (config.updateCheckEnabled || channelStatus?.switcherAvailable) {
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<h2>{{ 'updatesSection.title' | translate }}</h2>
|
<h2>{{ 'updatesSection.title' | translate }}</h2>
|
||||||
<p class="hint">{{ 'updatesSection.hint' | translate }}</p>
|
<p class="hint">{{ 'updatesSection.hint' | translate }}</p>
|
||||||
@if (licenseSuccess) {
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ licenseSuccess }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
<!-- Sous-section : canal stable -->
|
<!-- Sous-section : canal stable -->
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
@@ -64,201 +59,103 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
<!-- Sous-section : canal beta (Patreon) -->
|
<!-- Sous-section : canal beta (libre) -->
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
@if (licenseStatus?.enabled) {
|
@if (channelStatus) {
|
||||||
<div class="channel-block">
|
<div class="channel-block">
|
||||||
<h3 class="channel-title">
|
<h3 class="channel-title">
|
||||||
<lucide-icon [img]="Heart" [size]="16"></lucide-icon>
|
<lucide-icon [img]="FlaskConical" [size]="16"></lucide-icon>
|
||||||
{{ 'updatesSection.betaChannelTitle' | translate }}
|
{{ 'updatesSection.betaChannelTitle' | translate }}
|
||||||
</h3>
|
</h3>
|
||||||
<p class="hint" [innerHTML]="'updatesSection.betaChannelIntro' | translate"></p>
|
<p class="hint">{{ 'updatesSection.betaChannelIntro' | translate }}</p>
|
||||||
<!-- Pas de licence installee -->
|
<!-- En beta : une beta plus recente existe-t-elle ? -->
|
||||||
@if (licenseStatus?.status === 'NONE') {
|
@if (channelStatus.currentChannel === 'beta') {
|
||||||
<div class="form-row">
|
<div class="beta-status">
|
||||||
<button type="button" class="btn-primary" (click)="connectPatreon()">
|
@if (betaChecking) {
|
||||||
<lucide-icon [img]="Link2" [size]="16"></lucide-icon>
|
<div class="hint">{{ 'updatesSection.checkingBetaImages' | translate }}</div>
|
||||||
<span>{{ 'updatesSection.connectPatreon' | translate }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p class="hint">{{ 'updatesSection.connectInstructions' | translate }}</p>
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="license-jwt">{{ 'updatesSection.patreonToken' | translate }}</label>
|
|
||||||
<input
|
|
||||||
id="license-jwt"
|
|
||||||
type="text"
|
|
||||||
[(ngModel)]="licenseJwtInput"
|
|
||||||
placeholder="eyJhbGciOiJFZERTQS..."
|
|
||||||
autocomplete="off"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<button type="button" class="btn-primary" (click)="installLicense()" [disabled]="!licenseJwtInput.trim()">
|
|
||||||
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.activateLicense' | translate }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
@if (licenseError) {
|
|
||||||
<div class="alert alert-error">
|
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ licenseError }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<!-- Licence installee (VALID / GRACE / EXPIRED / UNVERIFIABLE) -->
|
|
||||||
@if (licenseStatus && licenseStatus.status !== 'NONE') {
|
|
||||||
@if (licenseStatus.status === 'VALID') {
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.licenseValid' | translate:{ tier: tierLabel(licenseStatus.tierId) } }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (licenseStatus.status === 'GRACE') {
|
|
||||||
<div class="alert alert-warn">
|
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.licenseGrace' | translate }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (licenseStatus.status === 'EXPIRED') {
|
|
||||||
<div class="alert alert-error">
|
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.licenseExpired' | translate }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (licenseStatus.status === 'UNVERIFIABLE') {
|
|
||||||
<div class="alert alert-error">
|
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.licenseUnverifiable' | translate }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<ul class="license-info">
|
|
||||||
@if (licenseStatus.tierId) {
|
|
||||||
<li [innerHTML]="'updatesSection.infoTier' | translate:{ tier: tierLabel(licenseStatus.tierId) }"></li>
|
|
||||||
}
|
}
|
||||||
@if (licenseStatus.expiresAt) {
|
@if (!betaChecking && betaStatus?.enabled) {
|
||||||
<li>
|
@if (betaStatus?.updateAvailable) {
|
||||||
<span [innerHTML]="'updatesSection.infoValidity' | translate:{ date: formatDate(licenseStatus.expiresAt) }"></span>
|
<div class="alert alert-success">
|
||||||
@if (daysUntilExpiry !== null && daysUntilExpiry > 0) {
|
<lucide-icon [img]="Download" [size]="16"></lucide-icon>
|
||||||
<span>
|
<span>{{ 'updatesSection.betaUpdateAvailable' | translate }}</span>
|
||||||
{{ (daysUntilExpiry > 1 ? 'updatesSection.renewalDays' : 'updatesSection.renewalDay') | translate:{ n: daysUntilExpiry } }}
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
@if (licenseStatus.lastRefreshAttemptAt) {
|
|
||||||
<li>
|
|
||||||
<span [innerHTML]="'updatesSection.infoLastRefresh' | translate:{ date: formatDate(licenseStatus.lastRefreshAttemptAt) }"></span>
|
|
||||||
@if (licenseStatus.lastRefreshSucceeded === true) {
|
|
||||||
<span class="badge-ok">{{ 'updatesSection.refreshOk' | translate }}</span>
|
|
||||||
}
|
|
||||||
@if (licenseStatus.lastRefreshSucceeded === false) {
|
|
||||||
<span class="badge-warn">{{ 'updatesSection.refreshFailed' | translate }}</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
<div class="form-row form-row-inline">
|
|
||||||
<label class="checkbox">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
[checked]="licenseStatus.betaChannelEnabled"
|
|
||||||
(change)="toggleBetaChannel(!licenseStatus.betaChannelEnabled)"
|
|
||||||
[disabled]="licenseStatus.status !== 'VALID' && licenseStatus.status !== 'GRACE'"
|
|
||||||
>
|
|
||||||
<span>{{ 'updatesSection.enableBetaChannel' | translate }}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-row form-row-actions">
|
|
||||||
<button type="button" class="btn-secondary" (click)="refreshLicense()" [disabled]="licenseLoading">
|
|
||||||
<lucide-icon [img]="RefreshCw" [size]="14"></lucide-icon>
|
|
||||||
<span>{{ (licenseLoading ? 'updatesSection.checking' : 'updatesSection.checkNow') | translate }}</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn-secondary btn-danger" (click)="disconnectPatreon()">
|
|
||||||
<lucide-icon [img]="Unlink" [size]="14"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.disconnectPatreon' | translate }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<!-- Etat du canal beta -->
|
|
||||||
@if (licenseStatus.betaChannelEnabled) {
|
|
||||||
<div class="beta-status">
|
|
||||||
@if (betaChecking) {
|
|
||||||
<div class="hint">{{ 'updatesSection.checkingBetaImages' | translate }}</div>
|
|
||||||
}
|
|
||||||
@if (!betaChecking && betaStatus && !betaStatus.enabled) {
|
|
||||||
<div class="hint">
|
|
||||||
{{ 'updatesSection.betaUnavailable' | translate:{ reason: betaStatus.disabledReason } }}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
@if (config.updateCheckEnabled) {
|
||||||
@if (!betaChecking && betaStatus?.enabled) {
|
<div class="form-row">
|
||||||
<div>
|
<button type="button" class="btn-primary" (click)="applyUpdate()" [disabled]="updateApplying">
|
||||||
@if (betaStatus?.anyUnknown) {
|
<lucide-icon [img]="Download" [size]="16"></lucide-icon>
|
||||||
<div class="alert alert-warn">
|
<span>{{ (updateApplying ? 'updatesSection.applying' : 'updatesSection.applyNow') | translate }}</span>
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
</button>
|
||||||
<span>{{ 'updatesSection.betaCheckImpossible' | translate }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<!-- Bascule de canal (stable <-> beta) via sidecar switcher -->
|
|
||||||
@if (channelStatus) {
|
|
||||||
<div class="channel-switch">
|
|
||||||
<div class="channel-current">
|
|
||||||
<span class="channel-label">{{ 'updatesSection.currentChannel' | translate }}</span>
|
|
||||||
<span class="channel-badge"
|
|
||||||
[class.channel-stable]="channelStatus.currentChannel === 'stable'"
|
|
||||||
[class.channel-beta]="channelStatus.currentChannel === 'beta'">
|
|
||||||
{{ (channelStatus.currentChannel === 'beta' ? 'updatesSection.channelBeta' : 'updatesSection.channelStable') | translate }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<!-- Sidecar dispo : boutons d'action -->
|
|
||||||
@if (channelStatus.switcherAvailable) {
|
|
||||||
<!-- On stable -> proposer passage beta (uniquement si licence active) -->
|
|
||||||
@if (channelStatus.currentChannel === 'stable') {
|
|
||||||
<button
|
|
||||||
type="button" class="btn-primary"
|
|
||||||
[disabled]="switchInFlight"
|
|
||||||
(click)="requestChannelSwitch('beta')">
|
|
||||||
<lucide-icon [img]="Download" [size]="14"></lucide-icon>
|
|
||||||
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToBeta') | translate }}</span>
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
<!-- On beta -> proposer retour stable -->
|
|
||||||
@if (channelStatus.currentChannel === 'beta') {
|
|
||||||
<button
|
|
||||||
type="button" class="btn-secondary"
|
|
||||||
[disabled]="switchInFlight"
|
|
||||||
(click)="requestChannelSwitch('stable')">
|
|
||||||
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
|
||||||
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToStable') | translate }}</span>
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
<!-- Switch en cours : on prévient que la page va se rendre injoignable -->
|
|
||||||
@if (switchInFlight) {
|
|
||||||
<div class="alert alert-warn">
|
|
||||||
<lucide-icon [img]="RefreshCw" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ 'updatesSection.switchInProgressNotice' | translate }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<!-- Erreur eventuelle remontee par le sidecar -->
|
} @else if (betaStatus?.anyUnknown) {
|
||||||
@if (switchError && !switchInFlight) {
|
|
||||||
<div class="alert alert-error">
|
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
|
||||||
<span>{{ switchError }}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<!-- Sidecar PAS dispo : fallback instructions manuelles (vieilles installs) -->
|
|
||||||
@if (!channelStatus.switcherAvailable) {
|
|
||||||
<div class="alert alert-warn">
|
<div class="alert alert-warn">
|
||||||
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
||||||
<span [innerHTML]="'updatesSection.switcherUnavailable' | translate"></span>
|
<span>{{ 'updatesSection.betaCheckImpossible' | translate }}</span>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="hint">
|
||||||
|
{{ 'updatesSection.betaUpToDate' | translate:{ date: (betaStatus?.checkedAt | date:'short') } }}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<!-- Bascule de canal (stable <-> beta) via sidecar switcher -->
|
||||||
|
<div class="channel-switch">
|
||||||
|
<div class="channel-current">
|
||||||
|
<span class="channel-label">{{ 'updatesSection.currentChannel' | translate }}</span>
|
||||||
|
<span class="channel-badge"
|
||||||
|
[class.channel-stable]="channelStatus.currentChannel === 'stable'"
|
||||||
|
[class.channel-beta]="channelStatus.currentChannel === 'beta'">
|
||||||
|
{{ (channelStatus.currentChannel === 'beta' ? 'updatesSection.channelBeta' : 'updatesSection.channelStable') | translate }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<!-- Sidecar dispo : boutons d'action -->
|
||||||
|
@if (channelStatus.switcherAvailable) {
|
||||||
|
<!-- On stable -> proposer passage beta -->
|
||||||
|
@if (channelStatus.currentChannel === 'stable') {
|
||||||
|
<button
|
||||||
|
type="button" class="btn-primary"
|
||||||
|
[disabled]="switchInFlight"
|
||||||
|
(click)="requestChannelSwitch('beta')">
|
||||||
|
<lucide-icon [img]="Download" [size]="14"></lucide-icon>
|
||||||
|
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToBeta') | translate }}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
<!-- On beta -> proposer retour stable -->
|
||||||
|
@if (channelStatus.currentChannel === 'beta') {
|
||||||
|
<button
|
||||||
|
type="button" class="btn-secondary"
|
||||||
|
[disabled]="switchInFlight"
|
||||||
|
(click)="requestChannelSwitch('stable')">
|
||||||
|
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
||||||
|
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToStable') | translate }}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
<!-- Switch en cours : on prévient que la page va se rendre injoignable -->
|
||||||
|
@if (switchInFlight) {
|
||||||
|
<div class="alert alert-warn">
|
||||||
|
<lucide-icon [img]="RefreshCw" [size]="16"></lucide-icon>
|
||||||
|
<span>{{ 'updatesSection.switchInProgressNotice' | translate }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<!-- Erreur eventuelle remontee par le sidecar -->
|
||||||
|
@if (switchError && !switchInFlight) {
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
||||||
|
<span>{{ switchError }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<!-- Sidecar PAS dispo : fallback instructions manuelles (vieilles installs) -->
|
||||||
|
@if (!channelStatus.switcherAvailable) {
|
||||||
|
<div class="alert alert-warn">
|
||||||
|
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
|
||||||
|
<span [innerHTML]="'updatesSection.switcherUnavailable' | translate"></span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { interval, switchMap, Subscription } from 'rxjs';
|
import { interval, switchMap, Subscription } from 'rxjs';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { LucideAngularModule, ArrowLeft, RefreshCw, Check, AlertCircle, Download, Heart, Link2, Unlink } from 'lucide-angular';
|
import { LucideAngularModule, ArrowLeft, RefreshCw, Check, AlertCircle, Download, FlaskConical } from 'lucide-angular';
|
||||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||||
import { UpdatesService, UpdateStatus } from '../../services/updates.service';
|
import { UpdatesService, UpdateStatus, BetaStatusDTO, ChannelStatusDTO, ChannelName } from '../../services/updates.service';
|
||||||
import { ConfigService } from '../../services/config.service';
|
import { ConfigService } from '../../services/config.service';
|
||||||
import { LicenseService, LicenseStatusDTO, BetaStatusDTO, ChannelStatusDTO, ChannelName } from '../../services/license.service';
|
|
||||||
import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog.service';
|
import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,8 +13,7 @@ import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog
|
|||||||
*
|
*
|
||||||
* Responsabilite unique : tout ce qui touche au CYCLE DE VIE des conteneurs —
|
* Responsabilite unique : tout ce qui touche au CYCLE DE VIE des conteneurs —
|
||||||
* - canal stable : verification + application des mises a jour (Watchtower) ;
|
* - canal stable : verification + application des mises a jour (Watchtower) ;
|
||||||
* - licence Patreon : connexion OAuth, installation du JWT, refresh, deconnexion ;
|
* - canal beta (libre) : verification des images beta quand on y tourne ;
|
||||||
* - canal beta : activation + verification des images beta ;
|
|
||||||
* - bascule de canal stable <-> beta via le sidecar switcher (avec polling).
|
* - bascule de canal stable <-> beta via le sidecar switcher (avec polling).
|
||||||
*
|
*
|
||||||
* Autonome : injecte ses propres services, aucun @Input/@Output — le parent
|
* Autonome : injecte ses propres services, aucun @Input/@Output — le parent
|
||||||
@@ -36,19 +34,9 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
readonly Check = Check;
|
readonly Check = Check;
|
||||||
readonly AlertCircle = AlertCircle;
|
readonly AlertCircle = AlertCircle;
|
||||||
readonly Download = Download;
|
readonly Download = Download;
|
||||||
readonly Heart = Heart;
|
readonly FlaskConical = FlaskConical;
|
||||||
readonly Link2 = Link2;
|
|
||||||
readonly Unlink = Unlink;
|
|
||||||
|
|
||||||
// --- Licence Patreon (canal beta) ---
|
/** Nouvelle beta disponible ? (verifie seulement quand l'instance tourne en beta). */
|
||||||
licenseStatus: LicenseStatusDTO | null = null;
|
|
||||||
licenseLoading = false;
|
|
||||||
licenseError = '';
|
|
||||||
/** Message de succes local a la section (connexion/deconnexion Patreon). */
|
|
||||||
licenseSuccess = '';
|
|
||||||
/** Token JWT colle par l'utilisateur apres OAuth. */
|
|
||||||
licenseJwtInput = '';
|
|
||||||
/** Etat du canal beta (digests des images privees). */
|
|
||||||
betaStatus: BetaStatusDTO | null = null;
|
betaStatus: BetaStatusDTO | null = null;
|
||||||
betaChecking = false;
|
betaChecking = false;
|
||||||
|
|
||||||
@@ -72,7 +60,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private updatesService: UpdatesService,
|
private updatesService: UpdatesService,
|
||||||
public config: ConfigService,
|
public config: ConfigService,
|
||||||
private licenseService: LicenseService,
|
|
||||||
private confirmDialog: ConfirmDialogService,
|
private confirmDialog: ConfirmDialogService,
|
||||||
private translate: TranslateService
|
private translate: TranslateService
|
||||||
) {}
|
) {}
|
||||||
@@ -81,7 +68,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
if (this.config.updateCheckEnabled) {
|
if (this.config.updateCheckEnabled) {
|
||||||
this.checkUpdates();
|
this.checkUpdates();
|
||||||
}
|
}
|
||||||
this.loadLicense();
|
|
||||||
this.loadChannelStatus();
|
this.loadChannelStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,103 +75,9 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
this.stopSwitchPolling();
|
this.stopSwitchPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Licence Patreon ---------------------------------------------------
|
|
||||||
|
|
||||||
loadLicense(): void {
|
|
||||||
this.licenseLoading = true;
|
|
||||||
this.licenseService.getStatus().subscribe({
|
|
||||||
next: (s) => {
|
|
||||||
this.licenseStatus = s;
|
|
||||||
this.licenseLoading = false;
|
|
||||||
if (s?.enabled && (s.status === 'VALID' || s.status === 'GRACE') && s.betaChannelEnabled) {
|
|
||||||
this.checkBeta();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: () => { this.licenseLoading = false; }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ouvre la page OAuth Patreon dans une nouvelle fenetre.
|
|
||||||
* L'utilisateur copie ensuite le JWT et le colle dans l'input ci-dessous.
|
|
||||||
*/
|
|
||||||
connectPatreon(): void {
|
|
||||||
this.licenseError = '';
|
|
||||||
this.licenseService.getConnectUrl().subscribe({
|
|
||||||
next: (r) => {
|
|
||||||
if (!r?.url) {
|
|
||||||
this.licenseError = this.translate.instant('updatesSection.connectUrlError');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.open(r.url, '_blank', 'noopener');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
installLicense(): void {
|
|
||||||
const jwt = this.licenseJwtInput.trim();
|
|
||||||
if (!jwt) {
|
|
||||||
this.licenseError = this.translate.instant('updatesSection.pasteTokenFirst');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.licenseError = '';
|
|
||||||
this.licenseService.install(jwt).subscribe((res) => {
|
|
||||||
// install() renvoie une union typée : le garde `in` suffit à discriminer.
|
|
||||||
if ('error' in res) {
|
|
||||||
this.licenseError = res.error;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.licenseStatus = res;
|
|
||||||
this.licenseJwtInput = '';
|
|
||||||
this.licenseSuccess = this.translate.instant('updatesSection.patreonConnectedSuccess');
|
|
||||||
if (this.licenseStatus.betaChannelEnabled) {
|
|
||||||
this.checkBeta();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshLicense(): void {
|
|
||||||
this.licenseLoading = true;
|
|
||||||
this.licenseService.refresh().subscribe({
|
|
||||||
next: (s) => {
|
|
||||||
this.licenseStatus = s;
|
|
||||||
this.licenseLoading = false;
|
|
||||||
},
|
|
||||||
error: () => { this.licenseLoading = false; }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnectPatreon(): void {
|
|
||||||
this.confirmDialog.confirm({
|
|
||||||
title: this.translate.instant('updatesSection.disconnectTitle'),
|
|
||||||
message: this.translate.instant('updatesSection.disconnectMessage'),
|
|
||||||
details: [this.translate.instant('updatesSection.disconnectDetail')],
|
|
||||||
confirmLabel: this.translate.instant('updatesSection.disconnectConfirm'),
|
|
||||||
variant: 'warning'
|
|
||||||
}).then(ok => {
|
|
||||||
if (!ok) return;
|
|
||||||
this.licenseService.disconnect().subscribe(() => {
|
|
||||||
this.licenseStatus = null;
|
|
||||||
this.betaStatus = null;
|
|
||||||
this.licenseSuccess = this.translate.instant('updatesSection.patreonDisconnected');
|
|
||||||
this.loadLicense();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleBetaChannel(enabled: boolean): void {
|
|
||||||
this.licenseService.setBetaChannel(enabled).subscribe({
|
|
||||||
next: (s) => {
|
|
||||||
if (s) this.licenseStatus = s;
|
|
||||||
if (enabled) this.checkBeta();
|
|
||||||
else this.betaStatus = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
checkBeta(): void {
|
checkBeta(): void {
|
||||||
this.betaChecking = true;
|
this.betaChecking = true;
|
||||||
this.licenseService.checkBeta().subscribe({
|
this.updatesService.checkBeta().subscribe({
|
||||||
next: (s) => {
|
next: (s) => {
|
||||||
this.betaStatus = s;
|
this.betaStatus = s;
|
||||||
this.betaChecking = false;
|
this.betaChecking = false;
|
||||||
@@ -197,11 +89,11 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
// --- Bascule de canal stable <-> beta --------------------------------------
|
// --- Bascule de canal stable <-> beta --------------------------------------
|
||||||
|
|
||||||
loadChannelStatus(): void {
|
loadChannelStatus(): void {
|
||||||
this.licenseService.getChannelStatus().subscribe({
|
this.updatesService.getChannelStatus().subscribe({
|
||||||
next: (s) => {
|
next: (s) => {
|
||||||
this.channelStatus = s;
|
this.channelStatus = s;
|
||||||
// Si on revient sur l'ecran apres un reload (post-switch reussi),
|
// En beta, on verifie aussi s'il existe une beta plus recente.
|
||||||
// on affiche le dernier resultat eventuel jusqu'a interaction utilisateur.
|
if (s?.currentChannel === 'beta') this.checkBeta();
|
||||||
},
|
},
|
||||||
error: () => { this.channelStatus = null; }
|
error: () => { this.channelStatus = null; }
|
||||||
});
|
});
|
||||||
@@ -210,8 +102,8 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Declenche un switch de canal. La sequence cote UI :
|
* Declenche un switch de canal. La sequence cote UI :
|
||||||
* 1. Confirm modal (action destructrice : recreate des containers)
|
* 1. Confirm modal (action destructrice : recreate des containers)
|
||||||
* 2. POST /api/license/channel/switch -> 202 avec l'ID de la commande
|
* 2. POST /api/admin/updates/channel/switch -> 202 avec l'ID de la commande
|
||||||
* 3. Polling /api/license/channel toutes les 2s jusqu'a status != IN_PROGRESS
|
* 3. Polling /api/admin/updates/channel toutes les 2s jusqu'a status != IN_PROGRESS
|
||||||
* 4. Si SUCCESS : la page va se rendre injoignable (Core recree). On affiche
|
* 4. Si SUCCESS : la page va se rendre injoignable (Core recree). On affiche
|
||||||
* "Recharge la page dans quelques secondes" et on essaie de poll quand
|
* "Recharge la page dans quelques secondes" et on essaie de poll quand
|
||||||
* meme — au retour de Core, on detectera SUCCESS et on rechargera auto.
|
* meme — au retour de Core, on detectera SUCCESS et on rechargera auto.
|
||||||
@@ -244,7 +136,7 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
private doChannelSwitch(target: ChannelName): void {
|
private doChannelSwitch(target: ChannelName): void {
|
||||||
this.switchInFlight = true;
|
this.switchInFlight = true;
|
||||||
this.switchError = '';
|
this.switchError = '';
|
||||||
this.licenseService.switchChannel(target).subscribe((res) => {
|
this.updatesService.switchChannel(target).subscribe((res) => {
|
||||||
if ('error' in res) {
|
if ('error' in res) {
|
||||||
this.switchError = res.error;
|
this.switchError = res.error;
|
||||||
this.switchInFlight = false;
|
this.switchInFlight = false;
|
||||||
@@ -256,14 +148,14 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Poll /api/license/channel toutes les 2s. S'arrete quand on detecte un
|
* Poll /api/admin/updates/channel toutes les 2s. S'arrete quand on detecte un
|
||||||
* resultat avec un ID >= a celui qu'on a soumis (le sidecar le met a jour
|
* resultat avec un ID >= a celui qu'on a soumis (le sidecar le met a jour
|
||||||
* a la fin de son traitement).
|
* a la fin de son traitement).
|
||||||
*/
|
*/
|
||||||
private startSwitchPolling(): void {
|
private startSwitchPolling(): void {
|
||||||
this.stopSwitchPolling();
|
this.stopSwitchPolling();
|
||||||
this.switchPollSub = interval(2000).pipe(
|
this.switchPollSub = interval(2000).pipe(
|
||||||
switchMap(() => this.licenseService.getChannelStatus())
|
switchMap(() => this.updatesService.getChannelStatus())
|
||||||
).subscribe((status) => {
|
).subscribe((status) => {
|
||||||
if (!status) return;
|
if (!status) return;
|
||||||
this.channelStatus = status;
|
this.channelStatus = status;
|
||||||
@@ -291,40 +183,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping tier_id Patreon → nom lisible. Les IDs viennent du dashboard
|
|
||||||
* Patreon de LoreMind (Settings -> Tiers). Sans entree dans la map, on
|
|
||||||
* affiche l'ID brut pour rester debuggable.
|
|
||||||
*
|
|
||||||
* Si tu ajoutes un nouveau tier Patreon, complete cette map et redeploie.
|
|
||||||
* (Pas besoin de toucher au backend — c'est juste un libelle d'UI.)
|
|
||||||
*/
|
|
||||||
private static readonly TIER_LABELS: Record<string, string> = {
|
|
||||||
'28448887': 'Compagnon',
|
|
||||||
// '0000000': 'Aventurier',
|
|
||||||
// '0000000': 'Heros',
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Libelle lisible d'un tier Patreon, fallback sur l'ID brut. */
|
|
||||||
tierLabel(tierId: string | null | undefined): string {
|
|
||||||
if (!tierId) return '';
|
|
||||||
return UpdatesSectionComponent.TIER_LABELS[tierId] ?? tierId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Format human-readable des dates renvoyees par le backend. */
|
|
||||||
formatDate(iso: string | null | undefined): string {
|
|
||||||
if (!iso) return '';
|
|
||||||
try { return new Date(iso).toLocaleString(); } catch { return iso; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Nombre de jours restants avant expiration JWT (peut etre negatif). */
|
|
||||||
get daysUntilExpiry(): number | null {
|
|
||||||
if (!this.licenseStatus?.expiresAt) return null;
|
|
||||||
const exp = new Date(this.licenseStatus.expiresAt).getTime();
|
|
||||||
const now = Date.now();
|
|
||||||
return Math.ceil((exp - now) / (1000 * 60 * 60 * 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Mises a jour conteneurs (canal stable) -----------------------------
|
// --- Mises a jour conteneurs (canal stable) -----------------------------
|
||||||
|
|
||||||
checkUpdates(): void {
|
checkUpdates(): void {
|
||||||
|
|||||||
@@ -1331,27 +1331,9 @@
|
|||||||
"upToDate": "Everything is up to date (checked on {{date}}).",
|
"upToDate": "Everything is up to date (checked on {{date}}).",
|
||||||
"applying": "Updating...",
|
"applying": "Updating...",
|
||||||
"applyNow": "Update now",
|
"applyNow": "Update now",
|
||||||
"betaChannelTitle": "Beta channel — patrons only",
|
"betaChannelTitle": "Beta channel",
|
||||||
"betaChannelIntro": "Support LoreMind on Patreon to access new features in preview. The <strong>Compagnon</strong> tier (€7/month) or higher unlocks this channel.",
|
"betaChannelIntro": "New features ahead of time, free and for everyone. A beta may contain bugs: your data is kept and you can go back to the stable channel at any time.",
|
||||||
"connectPatreon": "Connect my Patreon account",
|
|
||||||
"connectInstructions": "A new window will open to Patreon. After authorizing, copy the displayed token and paste it below.",
|
|
||||||
"patreonToken": "Patreon token",
|
|
||||||
"activateLicense": "Activate license",
|
|
||||||
"licenseValid": "Patreon account connected. Tier {{tier}} active.",
|
|
||||||
"licenseGrace": "Patreon connection expired, but beta access is maintained during the grace period. Make sure your Patreon subscription is still active and click \"Check now\".",
|
|
||||||
"licenseExpired": "Patreon connection expired too long ago. Reconnect to regain beta access.",
|
|
||||||
"licenseUnverifiable": "The installed token can no longer be verified. Reconnect.",
|
|
||||||
"infoTier": "<strong>Tier:</strong> {{tier}}",
|
|
||||||
"infoValidity": "<strong>Validity:</strong> until {{date}}",
|
|
||||||
"renewalDay": "(renews in {{n}} day)",
|
|
||||||
"renewalDays": "(renews in {{n}} days)",
|
|
||||||
"infoLastRefresh": "<strong>Last refresh:</strong> {{date}}",
|
|
||||||
"refreshOk": "OK",
|
|
||||||
"refreshFailed": "failed",
|
|
||||||
"enableBetaChannel": "Enable beta channel",
|
|
||||||
"disconnectPatreon": "Disconnect Patreon",
|
|
||||||
"checkingBetaImages": "Checking beta images...",
|
"checkingBetaImages": "Checking beta images...",
|
||||||
"betaUnavailable": "Unavailable: {{reason}}",
|
|
||||||
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
|
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
|
||||||
"currentChannel": "Current channel:",
|
"currentChannel": "Current channel:",
|
||||||
"channelBeta": "Beta",
|
"channelBeta": "Beta",
|
||||||
@@ -1361,14 +1343,6 @@
|
|||||||
"switching": "Switching...",
|
"switching": "Switching...",
|
||||||
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
|
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
|
||||||
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull && docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
|
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull && docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
|
||||||
"connectUrlError": "Unable to generate the connection URL. Check your config.",
|
|
||||||
"pasteTokenFirst": "First paste the token received after connecting with Patreon.",
|
|
||||||
"patreonConnectedSuccess": "Patreon account connected. Beta access is active.",
|
|
||||||
"disconnectTitle": "Disconnect Patreon",
|
|
||||||
"disconnectMessage": "Disconnect your Patreon account?",
|
|
||||||
"disconnectDetail": "You will lose access to the beta channel.",
|
|
||||||
"disconnectConfirm": "Disconnect",
|
|
||||||
"patreonDisconnected": "Patreon account disconnected.",
|
|
||||||
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
|
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
|
||||||
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
|
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
|
||||||
"switchToBetaTitle": "Switch to beta?",
|
"switchToBetaTitle": "Switch to beta?",
|
||||||
@@ -1382,7 +1356,9 @@
|
|||||||
"applyMessage": "Download and restart the containers now?",
|
"applyMessage": "Download and restart the containers now?",
|
||||||
"applyDetail": "The app will be unavailable for a few seconds.",
|
"applyDetail": "The app will be unavailable for a few seconds.",
|
||||||
"applyConfirm": "Update",
|
"applyConfirm": "Update",
|
||||||
"applyTriggered": "Update triggered. Reload the page in 30s."
|
"applyTriggered": "Update triggered. Reload the page in 30s.",
|
||||||
|
"betaUpdateAvailable": "A new beta is available.",
|
||||||
|
"betaUpToDate": "Beta up to date (checked on {{date}})."
|
||||||
},
|
},
|
||||||
"itemCatalogEdit": {
|
"itemCatalogEdit": {
|
||||||
"editTitle": "Edit catalog",
|
"editTitle": "Edit catalog",
|
||||||
|
|||||||
@@ -1331,27 +1331,9 @@
|
|||||||
"upToDate": "Tout est à jour (vérifié le {{date}}).",
|
"upToDate": "Tout est à jour (vérifié le {{date}}).",
|
||||||
"applying": "Mise à jour en cours...",
|
"applying": "Mise à jour en cours...",
|
||||||
"applyNow": "Mettre à jour maintenant",
|
"applyNow": "Mettre à jour maintenant",
|
||||||
"betaChannelTitle": "Canal beta — réservé aux patrons",
|
"betaChannelTitle": "Canal bêta",
|
||||||
"betaChannelIntro": "Soutiens LoreMind sur Patreon pour accéder aux nouvelles features en avant-première. Le tier <strong>Compagnon</strong> (7€/mois) ou supérieur débloque ce canal.",
|
"betaChannelIntro": "Les nouveautés en avant-première, gratuitement et pour tout le monde. Une bêta peut contenir des bugs : tes données sont conservées et tu peux revenir au canal stable à tout moment.",
|
||||||
"connectPatreon": "Connecter mon compte Patreon",
|
|
||||||
"connectInstructions": "Une nouvelle fenêtre va s'ouvrir vers Patreon. Après autorisation, copie le token affiché et colle-le ci-dessous.",
|
|
||||||
"patreonToken": "Token Patreon",
|
|
||||||
"activateLicense": "Activer la licence",
|
|
||||||
"licenseValid": "Compte Patreon connecté. Tier {{tier}} actif.",
|
|
||||||
"licenseGrace": "Connexion Patreon expirée, mais accès beta maintenu pendant la période de tolérance. Vérifie que ton abonnement Patreon est toujours actif et clique sur \"Vérifier maintenant\".",
|
|
||||||
"licenseExpired": "Connexion Patreon expirée depuis trop longtemps. Reconnecte-toi pour retrouver l'accès beta.",
|
|
||||||
"licenseUnverifiable": "Le token installé ne peut plus être vérifié. Reconnecte-toi.",
|
|
||||||
"infoTier": "<strong>Tier :</strong> {{tier}}",
|
|
||||||
"infoValidity": "<strong>Validité :</strong> jusqu'au {{date}}",
|
|
||||||
"renewalDay": "(renouvellement dans {{n}} jour)",
|
|
||||||
"renewalDays": "(renouvellement dans {{n}} jours)",
|
|
||||||
"infoLastRefresh": "<strong>Dernier refresh :</strong> {{date}}",
|
|
||||||
"refreshOk": "OK",
|
|
||||||
"refreshFailed": "échec",
|
|
||||||
"enableBetaChannel": "Activer le canal beta",
|
|
||||||
"disconnectPatreon": "Déconnecter Patreon",
|
|
||||||
"checkingBetaImages": "Vérification des images beta...",
|
"checkingBetaImages": "Vérification des images beta...",
|
||||||
"betaUnavailable": "Indisponible : {{reason}}",
|
|
||||||
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
|
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
|
||||||
"currentChannel": "Canal actuel :",
|
"currentChannel": "Canal actuel :",
|
||||||
"channelBeta": "Bêta",
|
"channelBeta": "Bêta",
|
||||||
@@ -1361,14 +1343,6 @@
|
|||||||
"switching": "Bascule en cours...",
|
"switching": "Bascule en cours...",
|
||||||
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
|
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
|
||||||
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull && docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
|
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull && docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
|
||||||
"connectUrlError": "Impossible de générer l'URL de connexion. Vérifie ta config.",
|
|
||||||
"pasteTokenFirst": "Colle d'abord le token reçu après connexion Patreon.",
|
|
||||||
"patreonConnectedSuccess": "Compte Patreon connecté. L'accès beta est actif.",
|
|
||||||
"disconnectTitle": "Déconnecter Patreon",
|
|
||||||
"disconnectMessage": "Déconnecter ton compte Patreon ?",
|
|
||||||
"disconnectDetail": "Tu perdras l'accès au canal beta.",
|
|
||||||
"disconnectConfirm": "Déconnecter",
|
|
||||||
"patreonDisconnected": "Compte Patreon déconnecté.",
|
|
||||||
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
|
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
|
||||||
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
|
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
|
||||||
"switchToBetaTitle": "Passer en beta ?",
|
"switchToBetaTitle": "Passer en beta ?",
|
||||||
@@ -1382,7 +1356,9 @@
|
|||||||
"applyMessage": "Télécharger et redémarrer les conteneurs maintenant ?",
|
"applyMessage": "Télécharger et redémarrer les conteneurs maintenant ?",
|
||||||
"applyDetail": "L'app sera indisponible quelques secondes.",
|
"applyDetail": "L'app sera indisponible quelques secondes.",
|
||||||
"applyConfirm": "Mettre à jour",
|
"applyConfirm": "Mettre à jour",
|
||||||
"applyTriggered": "Mise à jour déclenchée. Rechargez la page dans 30s."
|
"applyTriggered": "Mise à jour déclenchée. Rechargez la page dans 30s.",
|
||||||
|
"betaUpdateAvailable": "Une nouvelle bêta est disponible.",
|
||||||
|
"betaUpToDate": "Bêta à jour (vérifiée le {{date}})."
|
||||||
},
|
},
|
||||||
"itemCatalogEdit": {
|
"itemCatalogEdit": {
|
||||||
"editTitle": "Éditer le catalogue",
|
"editTitle": "Éditer le catalogue",
|
||||||
|
|||||||
@@ -95,28 +95,12 @@
|
|||||||
"upToDate": "Everything is up to date (checked on {{date}}).",
|
"upToDate": "Everything is up to date (checked on {{date}}).",
|
||||||
"applying": "Updating...",
|
"applying": "Updating...",
|
||||||
"applyNow": "Update now",
|
"applyNow": "Update now",
|
||||||
"betaChannelTitle": "Beta channel — patrons only",
|
"betaChannelTitle": "Beta channel",
|
||||||
"betaChannelIntro": "Support LoreMind on Patreon to access new features in preview. The <strong>Compagnon</strong> tier (€7/month) or higher unlocks this channel.",
|
"betaChannelIntro": "New features ahead of time, free and for everyone. A beta may contain bugs: your data is kept and you can go back to the stable channel at any time.",
|
||||||
"connectPatreon": "Connect my Patreon account",
|
|
||||||
"connectInstructions": "A new window will open to Patreon. After authorizing, copy the displayed token and paste it below.",
|
|
||||||
"patreonToken": "Patreon token",
|
|
||||||
"activateLicense": "Activate license",
|
|
||||||
"licenseValid": "Patreon account connected. Tier {{tier}} active.",
|
|
||||||
"licenseGrace": "Patreon connection expired, but beta access is maintained during the grace period. Make sure your Patreon subscription is still active and click \"Check now\".",
|
|
||||||
"licenseExpired": "Patreon connection expired too long ago. Reconnect to regain beta access.",
|
|
||||||
"licenseUnverifiable": "The installed token can no longer be verified. Reconnect.",
|
|
||||||
"infoTier": "<strong>Tier:</strong> {{tier}}",
|
|
||||||
"infoValidity": "<strong>Validity:</strong> until {{date}}",
|
|
||||||
"renewalDay": "(renews in {{n}} day)",
|
|
||||||
"renewalDays": "(renews in {{n}} days)",
|
|
||||||
"infoLastRefresh": "<strong>Last refresh:</strong> {{date}}",
|
|
||||||
"refreshOk": "OK",
|
|
||||||
"refreshFailed": "failed",
|
|
||||||
"enableBetaChannel": "Enable beta channel",
|
|
||||||
"disconnectPatreon": "Disconnect Patreon",
|
|
||||||
"checkingBetaImages": "Checking beta images...",
|
"checkingBetaImages": "Checking beta images...",
|
||||||
"betaUnavailable": "Unavailable: {{reason}}",
|
|
||||||
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
|
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
|
||||||
|
"betaUpdateAvailable": "A new beta is available.",
|
||||||
|
"betaUpToDate": "Beta up to date (checked on {{date}}).",
|
||||||
"currentChannel": "Current channel:",
|
"currentChannel": "Current channel:",
|
||||||
"channelBeta": "Beta",
|
"channelBeta": "Beta",
|
||||||
"channelStable": "Stable",
|
"channelStable": "Stable",
|
||||||
@@ -125,14 +109,6 @@
|
|||||||
"switching": "Switching...",
|
"switching": "Switching...",
|
||||||
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
|
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
|
||||||
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull && docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
|
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull && docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
|
||||||
"connectUrlError": "Unable to generate the connection URL. Check your config.",
|
|
||||||
"pasteTokenFirst": "First paste the token received after connecting with Patreon.",
|
|
||||||
"patreonConnectedSuccess": "Patreon account connected. Beta access is active.",
|
|
||||||
"disconnectTitle": "Disconnect Patreon",
|
|
||||||
"disconnectMessage": "Disconnect your Patreon account?",
|
|
||||||
"disconnectDetail": "You will lose access to the beta channel.",
|
|
||||||
"disconnectConfirm": "Disconnect",
|
|
||||||
"patreonDisconnected": "Patreon account disconnected.",
|
|
||||||
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
|
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
|
||||||
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
|
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
|
||||||
"switchToBetaTitle": "Switch to beta?",
|
"switchToBetaTitle": "Switch to beta?",
|
||||||
|
|||||||
@@ -95,28 +95,12 @@
|
|||||||
"upToDate": "Tout est à jour (vérifié le {{date}}).",
|
"upToDate": "Tout est à jour (vérifié le {{date}}).",
|
||||||
"applying": "Mise à jour en cours...",
|
"applying": "Mise à jour en cours...",
|
||||||
"applyNow": "Mettre à jour maintenant",
|
"applyNow": "Mettre à jour maintenant",
|
||||||
"betaChannelTitle": "Canal beta — réservé aux patrons",
|
"betaChannelTitle": "Canal bêta",
|
||||||
"betaChannelIntro": "Soutiens LoreMind sur Patreon pour accéder aux nouvelles features en avant-première. Le tier <strong>Compagnon</strong> (7€/mois) ou supérieur débloque ce canal.",
|
"betaChannelIntro": "Les nouveautés en avant-première, gratuitement et pour tout le monde. Une bêta peut contenir des bugs : tes données sont conservées et tu peux revenir au canal stable à tout moment.",
|
||||||
"connectPatreon": "Connecter mon compte Patreon",
|
|
||||||
"connectInstructions": "Une nouvelle fenêtre va s'ouvrir vers Patreon. Après autorisation, copie le token affiché et colle-le ci-dessous.",
|
|
||||||
"patreonToken": "Token Patreon",
|
|
||||||
"activateLicense": "Activer la licence",
|
|
||||||
"licenseValid": "Compte Patreon connecté. Tier {{tier}} actif.",
|
|
||||||
"licenseGrace": "Connexion Patreon expirée, mais accès beta maintenu pendant la période de tolérance. Vérifie que ton abonnement Patreon est toujours actif et clique sur \"Vérifier maintenant\".",
|
|
||||||
"licenseExpired": "Connexion Patreon expirée depuis trop longtemps. Reconnecte-toi pour retrouver l'accès beta.",
|
|
||||||
"licenseUnverifiable": "Le token installé ne peut plus être vérifié. Reconnecte-toi.",
|
|
||||||
"infoTier": "<strong>Tier :</strong> {{tier}}",
|
|
||||||
"infoValidity": "<strong>Validité :</strong> jusqu'au {{date}}",
|
|
||||||
"renewalDay": "(renouvellement dans {{n}} jour)",
|
|
||||||
"renewalDays": "(renouvellement dans {{n}} jours)",
|
|
||||||
"infoLastRefresh": "<strong>Dernier refresh :</strong> {{date}}",
|
|
||||||
"refreshOk": "OK",
|
|
||||||
"refreshFailed": "échec",
|
|
||||||
"enableBetaChannel": "Activer le canal beta",
|
|
||||||
"disconnectPatreon": "Déconnecter Patreon",
|
|
||||||
"checkingBetaImages": "Vérification des images beta...",
|
"checkingBetaImages": "Vérification des images beta...",
|
||||||
"betaUnavailable": "Indisponible : {{reason}}",
|
|
||||||
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
|
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
|
||||||
|
"betaUpdateAvailable": "Une nouvelle bêta est disponible.",
|
||||||
|
"betaUpToDate": "Bêta à jour (vérifiée le {{date}}).",
|
||||||
"currentChannel": "Canal actuel :",
|
"currentChannel": "Canal actuel :",
|
||||||
"channelBeta": "Bêta",
|
"channelBeta": "Bêta",
|
||||||
"channelStable": "Stable",
|
"channelStable": "Stable",
|
||||||
@@ -125,14 +109,6 @@
|
|||||||
"switching": "Bascule en cours...",
|
"switching": "Bascule en cours...",
|
||||||
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
|
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
|
||||||
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull && docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
|
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull && docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
|
||||||
"connectUrlError": "Impossible de générer l'URL de connexion. Vérifie ta config.",
|
|
||||||
"pasteTokenFirst": "Colle d'abord le token reçu après connexion Patreon.",
|
|
||||||
"patreonConnectedSuccess": "Compte Patreon connecté. L'accès beta est actif.",
|
|
||||||
"disconnectTitle": "Déconnecter Patreon",
|
|
||||||
"disconnectMessage": "Déconnecter ton compte Patreon ?",
|
|
||||||
"disconnectDetail": "Tu perdras l'accès au canal beta.",
|
|
||||||
"disconnectConfirm": "Déconnecter",
|
|
||||||
"patreonDisconnected": "Compte Patreon déconnecté.",
|
|
||||||
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
|
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
|
||||||
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
|
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
|
||||||
"switchToBetaTitle": "Passer en beta ?",
|
"switchToBetaTitle": "Passer en beta ?",
|
||||||
|
|||||||
Reference in New Issue
Block a user