opencode ergebnis V0.1

This commit is contained in:
concierge committed 2026-10-23 00:05:06 +02:00
1 parent 61d86a3d83
commit 7e498ebc3f
71 files changed
+28982 -46

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
"""
API Auth Endpunkte
"""
from flask import Blueprint, jsonify, g, session
from cmbnet.auth import login_required
from cmbnet.db import get_db
import secrets
from datetime import datetime, timedelta
api_auth_bp = Blueprint('api_auth', __name__)
@api_auth_bp.route('/auth/ws-token', methods=['GET', 'POST'])
@login_required
def ws_token(**kwargs):
"""Erzeugt ein Zugriffstoken für WebSocket-Authentifizierung"""
db = get_db()
token = secrets.token_urlsafe(32)
expires_at = datetime.now() + timedelta(hours=1)
db.execute(
'INSERT INTO ws_tokens (tenant_id, account_id, token, expires_at) VALUES (?, ?, ?, ?)',
(g.tenant_id, session['account_id'], token, expires_at)
)
db.commit()
return jsonify({'token': token})