refactor: OnlyOffice Konfiguration nur ueber .env, nicht Admin-GUI

OnlyOffice URL und JWT Secret kommen jetzt ausschliesslich aus der
.env Datei (Umgebungsvariablen), nicht mehr aus der Admin-GUI:
- ONLYOFFICE_URL und ONLYOFFICE_JWT_SECRET in .env setzen
- docker-compose liest das gleiche Secret fuer den OnlyOffice-Container
- Eine Quelle der Wahrheit, kein Sync zwischen .env und DB noetig

Admin-GUI zeigt jetzt nur noch den Status an:
- Konfiguriert / Nicht konfiguriert (Tag)
- Aktuelle URL
- JWT Secret gesetzt / Fehlt (Tag)
- Setup-Anleitung mit .env Beispiel

Behebt: "Sicherheitstoken nicht korrekt" wenn OnlyOffice laeuft
aber JWT Secret nicht uebereinstimmt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Hacker
2026-04-11 22:08:07 +02:00
parent 5bf98302e3
commit 0dbeef7cd9
3 changed files with 39 additions and 29 deletions
+3 -3
View File
@@ -330,7 +330,7 @@ def onlyoffice_config(file_id):
if err:
return err
oo_url = AppSettings.get('onlyoffice_url', os.environ.get('ONLYOFFICE_URL', ''))
oo_url = os.environ.get('ONLYOFFICE_URL', '')
if not oo_url:
return jsonify({'error': 'OnlyOffice nicht konfiguriert', 'available': False}), 200
@@ -381,7 +381,7 @@ def onlyoffice_config(file_id):
}
# Sign with JWT if secret is set
jwt_secret = AppSettings.get('onlyoffice_jwt_secret', '')
jwt_secret = os.environ.get('ONLYOFFICE_JWT_SECRET', '')
if jwt_secret:
import jwt as pyjwt
config['config']['token'] = pyjwt.encode(config['config'], jwt_secret, algorithm='HS256')
@@ -448,7 +448,7 @@ def onlyoffice_callback():
@token_required
def onlyoffice_status():
"""Check if OnlyOffice is available."""
oo_url = AppSettings.get('onlyoffice_url', os.environ.get('ONLYOFFICE_URL', ''))
oo_url = os.environ.get('ONLYOFFICE_URL', '')
return jsonify({
'available': bool(oo_url),
'url': oo_url,
+4 -6
View File
@@ -153,9 +153,9 @@ def get_settings():
'system_smtp_username': AppSettings.get('system_smtp_username', ''),
'system_smtp_password_set': bool(AppSettings.get('system_smtp_password', '')),
'system_email_from': AppSettings.get('system_email_from', ''),
'onlyoffice_url': AppSettings.get('onlyoffice_url', os.environ.get('ONLYOFFICE_URL', '')),
'onlyoffice_jwt_secret': AppSettings.get('onlyoffice_jwt_secret', ''),
'onlyoffice_jwt_secret_set': bool(AppSettings.get('onlyoffice_jwt_secret', '')),
'onlyoffice_url': os.environ.get('ONLYOFFICE_URL', ''),
'onlyoffice_configured': bool(os.environ.get('ONLYOFFICE_URL', '')),
'onlyoffice_jwt_set': bool(os.environ.get('ONLYOFFICE_JWT_SECRET', '')),
}), 200
@@ -166,13 +166,11 @@ def update_settings():
if 'public_registration' in data:
AppSettings.set('public_registration', str(data['public_registration']).lower())
for key in ['system_smtp_host', 'system_smtp_port', 'system_smtp_ssl',
'system_smtp_username', 'system_email_from', 'onlyoffice_url']:
'system_smtp_username', 'system_email_from']:
if key in data:
AppSettings.set(key, str(data[key]))
if 'system_smtp_password' in data and data['system_smtp_password']:
AppSettings.set('system_smtp_password', data['system_smtp_password'])
if 'onlyoffice_jwt_secret' in data and data['onlyoffice_jwt_secret']:
AppSettings.set('onlyoffice_jwt_secret', data['onlyoffice_jwt_secret'])
return jsonify({'message': 'Einstellungen gespeichert'}), 200