Compare commits

...
8 Commits
Author SHA1 Message Date
MasutaYunikon ac6ac46a14 Merge pull request #13 from Masutayunikon/release-please--branches--main
chore(main): release 1.5.0
2026-03-11 15:47:04 +01:00
MasutaYunikon 66f5771ca7 chore(main): release 1.5.0 2026-03-11 15:45:33 +01:00
MasutaYunikon 40a12a870b Merge remote-tracking branch 'origin/main' 2026-03-11 15:45:08 +01:00
MasutaYunikon e7afe138e1 feat(auth): génération automatique du JWT secret au démarrage
- secret.ts: génère un secret aléatoire 96 chars hex si absent
- secret.ts: persiste dans data/secret.key (mode 600)
- secret.ts: priorité env JWT_SECRET > secret.key > génération
- auth: import JWT_SECRET depuis secret.ts au lieu de process.env
- docker-compose: JWT_SECRET optionnel (géré automatiquement)
- readme: mise à jour — JWT_SECRET n'est plus obligatoire
- feat: add favicon.ico
2026-03-11 15:45:00 +01:00
MasutaYunikon 8656e7fa36 Merge pull request #12 from Masutayunikon/release-please--branches--main
chore(main): release 1.4.1
2026-03-11 15:17:46 +01:00
MasutaYunikon d21ddd6dfc chore(main): release 1.4.1 2026-03-11 15:15:58 +01:00
MasutaYunikon 867186db98 Merge remote-tracking branch 'origin/main' 2026-03-11 15:15:35 +01:00
MasutaYunikon dd320e92dc fix: logger third args 2026-03-11 15:15:25 +01:00
5 changed files with 63 additions and 5 deletions

No files matched your search

+14
View File
@@ -1,5 +1,19 @@
# Changelog
## [1.5.0](https://github.com/Masutayunikon/FanKarr/compare/v1.4.1...v1.5.0) (2026-03-11)
### Features
* **auth:** génération automatique du JWT secret au démarrage ([eaa52e9](https://github.com/Masutayunikon/FanKarr/commit/eaa52e90900ff0e198beae190d7ad0298a702482))
## [1.4.1](https://github.com/Masutayunikon/FanKarr/compare/v1.4.0...v1.4.1) (2026-03-11)
### Bug Fixes
* logger third args ([5abac1e](https://github.com/Masutayunikon/FanKarr/commit/5abac1e11236ed1e8f7f0de7f0cff881d1b60f10))
## [1.4.0](https://github.com/Masutayunikon/FanKarr/compare/v1.3.0...v1.4.0) (2026-03-11)
+3 -3
View File
@@ -3,9 +3,9 @@ import path from 'path'
import bcrypt from 'bcrypt'
import jwt from 'jsonwebtoken'
import type { Request, Response, NextFunction } from 'express'
import { JWT_SECRET } from './secret.js'
const DATA_PATH = path.join(process.cwd(), 'data', 'auth.json')
const JWT_SECRET = process.env.JWT_SECRET || 'fankarr-secret-change-me'
const SALT_ROUNDS = 10
interface AuthData {
@@ -63,7 +63,7 @@ export function authSetup(req: Request, res: Response): void {
const passwordHash = bcrypt.hashSync(password, SALT_ROUNDS)
writeAuth({ username, passwordHash })
const token = jwt.sign({ username }, JWT_SECRET, { expiresIn: '30d' })
const token = jwt.sign({ username }, JWT_SECRET, { expiresIn: '1d' })
res.cookie('fankarr_token', token, { httpOnly: true, sameSite: 'lax' })
res.json({ success: true })
}
@@ -87,7 +87,7 @@ export function authLogin(req: Request, res: Response): void {
return
}
const token = jwt.sign({ username }, JWT_SECRET, { expiresIn: '30d' })
const token = jwt.sign({ username }, JWT_SECRET, { expiresIn: '1d' })
res.cookie('fankarr_token', token, { httpOnly: true, sameSite: 'lax' })
res.json({ success: true })
}
+1 -1
View File
@@ -120,7 +120,7 @@ export async function autoOrganizeAll(
try {
torrents = await listFn()
} catch (err) {
logger.error('organize', "Impossible de récupérer la liste des torrents:", err)
logger.error('organize', "Impossible de récupérer la liste des torrents: " + (err instanceof Error ? err.message : String(err)))
return
}
+44
View File
@@ -0,0 +1,44 @@
/**
* secret.ts
* =========
* Génère et persiste le JWT secret dans data/secret.key
* Si JWT_SECRET est défini en variable d'environnement, il est utilisé tel quel.
* Sinon, on lit data/secret.key — s'il n'existe pas, on en génère un et on le sauvegarde.
*/
import fs from 'fs'
import path from 'path'
import crypto from 'crypto'
const SECRET_PATH = path.join(process.cwd(), 'data', 'secret.key')
function generateSecret(): string {
return crypto.randomBytes(48).toString('hex')
}
function loadOrCreateSecret(): string {
// 1. Variable d'environnement — priorité absolue
if (process.env.JWT_SECRET && process.env.JWT_SECRET !== 'fankarr-secret-change-me') {
return process.env.JWT_SECRET
}
// 2. Fichier existant
if (fs.existsSync(SECRET_PATH)) {
const secret = fs.readFileSync(SECRET_PATH, 'utf-8').trim()
if (secret.length > 0) return secret
}
// 3. Génération + sauvegarde
const secret = generateSecret()
try {
fs.mkdirSync(path.dirname(SECRET_PATH), { recursive: true })
fs.writeFileSync(SECRET_PATH, secret, { encoding: 'utf-8', mode: 0o600 })
console.log('[auth] JWT secret généré et sauvegardé dans data/secret.key')
} catch (err) {
console.error('[auth] Impossible de sauvegarder le secret:', err)
}
return secret
}
export const JWT_SECRET: string = loadOrCreateSecret()
+1 -1
View File
@@ -273,7 +273,7 @@ async function download(key: string, torrent_url: string | null, magnet: string
downloading.value = key
const result = await store.download(torrent_url, magnet)
downloading.value = null
if (result.success) showToast('success', 'Ajouté à qBittorrent !')
if (result.success) showToast('success', 'Téléchargement lancé')
else showToast('error', result.error ?? 'Erreur inconnue')
}