svg keepass

This commit is contained in:
Arno
2025-07-26 18:22:49 +00:00
parent 1a8f4d6613
commit 2ab1955ce2
5 changed files with 67 additions and 8 deletions

2
.gitignore vendored
View File

@ -16,6 +16,8 @@
/services/40-keycloak/volume/realm/realm-export.json
/services/50-keeweb/volume
/services/50-komga/volume
/services/50-nextcloud/volume/data

View File

@ -1,21 +1,78 @@
const webdav = require('webdav-server').v2;
const fs = require('fs');
const path = require('path');
const adminUser = process.env.WEBDAV_USER || 'admin';
const adminPass = process.env.WEBDAV_PASS || 'password';
const WEB_URL = process.env.WEB_URL || 'localhost';
const PROTOCOLE = process.env.PROTOCOLE || 'http';
const ALLOWED_ORIGIN = `${PROTOCOLE}://${WEB_URL}`;
const ROOT_DIR = '/data';
// Auth
const userManager = new webdav.SimpleUserManager();
const user = userManager.addUser(adminUser, adminPass, false); // false = pas admin système
const user = userManager.addUser(adminUser, adminPass, false);
const privilegeManager = new webdav.SimplePathPrivilegeManager();
privilegeManager.setRights(user, '/', ['all']);
// ✅ LoggingFileSystem étend PhysicalFileSystem
class LoggingFileSystem extends webdav.PhysicalFileSystem {
move(ctx, source, destination, callback) {
console.log(`🟡 MOVE requested from ${source.toString()} to ${destination.toString()}`);
const srcPath = path.join(ROOT_DIR, source.toString());
const destPath = path.join(ROOT_DIR, destination.toString());
fs.promises.mkdir(path.dirname(destPath), { recursive: true })
.then(() => fs.promises.rename(srcPath, destPath))
.then(() => {
console.log(`✅ MOVE succeeded: ${srcPath} -> ${destPath}`);
if (typeof callback === 'function') callback(null);
})
.catch(err => {
console.error(`❌ MOVE failed: ${err.message}`);
if (typeof callback === 'function') callback(err);
});
}
}
// Serveur WebDAV
const server = new webdav.WebDAVServer({
port: 9999,
hostname: '0.0.0.0',
httpAuthentication: new webdav.HTTPBasicAuthentication(userManager, 'default realm'),
privilegeManager,
rootFileSystem: new webdav.PhysicalFileSystem('/data')
rootFileSystem: new LoggingFileSystem(ROOT_DIR),
responseHeaders: {
'Access-Control-Allow-Origin': ALLOWED_ORIGIN,
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': 'Authorization, Depth, Content-Type',
'Access-Control-Allow-Methods': 'GET, PUT, OPTIONS, MKCOL, PROPFIND, DELETE, COPY, MOVE, LOCK, UNLOCK'
}
});
server.start(() => {
console.log(`WebDAV server running at http://0.0.0.0:9999 as ${adminUser}`);
// Ajout header Last-Modified
server.beforeRequest((arg, next) => {
const { request, response, requested } = arg;
if (request.method === 'GET' || request.method === 'HEAD') {
const filePath = path.join(ROOT_DIR, decodeURIComponent(requested.path.toString()));
fs.stat(filePath, (err, stats) => {
if (!err && stats.isFile()) {
response.setHeader('Last-Modified', stats.mtime.toUTCString());
console.log(`[INFO] Added Last-Modified: ${stats.mtime.toUTCString()} for ${filePath}`);
}
next();
});
} else {
next();
}
});
// Start
server.start(() => {
console.log(`✅ WebDAV server ready at http://0.0.0.0:9999`);
console.log(`🔐 Auth: user="${adminUser}", pass="***"`);
console.log(`🌐 CORS: Allow-Origin = ${ALLOWED_ORIGIN}`);
});

View File

@ -1,4 +1,4 @@
# Keeweb
ProxyPass /keeweb http://keeweb retry=0 keepalive=On
ProxyPassReverse /keeweb http://keeweb retry=0
ProxyPass /keeweb http://keeweb/keeweb retry=0 keepalive=On
ProxyPassReverse /keeweb http://keeweb/keeweb retry=0

View File

@ -10,4 +10,4 @@ services:
networks:
- nine-network
volumes:
- ./services/50-keeweb/volume/data:/web
- ./services/50-keeweb/volume/data:/data