feat: agent-02-kiosk Phase 1 - NFC UID migration + session service

- Migration 0025: kiosk_nfc_uid column on users table with partial unique index per company
- User model: kiosk_nfc_uid field after personnel_number
- New service: kiosk_session_service.py (Redis-based 15min sessions)
- New core module: app/core/redis.py (sync Redis client with ping-test)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 12:45:47 +02:00
parent 1db7164837
commit 094863f94b
5 changed files with 232 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Redis-Client für TimeMaster (sync, für Kiosk-Nonce-Cache und Sessions)."""
from __future__ import annotations
import logging
from typing import Optional
log = logging.getLogger(__name__)
_redis_client = None
def get_redis_client():
"""Gibt den Redis-Client zurück oder None wenn nicht konfiguriert/erreichbar."""
global _redis_client
if _redis_client is not None:
return _redis_client
try:
import redis as redis_lib
from app.core.config import settings
url = getattr(settings, "redis_url", "redis://localhost:6379/0")
_redis_client = redis_lib.from_url(url, decode_responses=True, socket_connect_timeout=2)
# Verbindung testen
_redis_client.ping()
log.info("Redis-Verbindung hergestellt: %s", url)
return _redis_client
except Exception as exc:
log.warning("Redis nicht verfügbar: %s", exc)
return None