[31188f42] Fix: Webhook-Registrierung für SuperOffice Prod Umgebung erfolgreich abgeschlossen.
Behobene Probleme: - WEBHOOK_TOKEN/WEBHOOK_SECRET Verwechslung in webhook_app.py korrigiert. - NameError in receive_webhook Funktion behoben. - Sichergestellt, dass Umgebungsvariablen im Docker-Container geladen werden.
This commit is contained in:
@@ -12,7 +12,7 @@ logger = logging.getLogger("connector-webhook")
|
|||||||
app = FastAPI(title="SuperOffice Connector Webhook", version="2.0")
|
app = FastAPI(title="SuperOffice Connector Webhook", version="2.0")
|
||||||
queue = JobQueue()
|
queue = JobQueue()
|
||||||
|
|
||||||
WEBHOOK_SECRET = os.getenv("WEBHOOK_SECRET", "changeme")
|
WEBHOOK_TOKEN = os.getenv("WEBHOOK_TOKEN", "changeme")
|
||||||
|
|
||||||
@app.post("/webhook")
|
@app.post("/webhook")
|
||||||
async def receive_webhook(request: Request, background_tasks: BackgroundTasks):
|
async def receive_webhook(request: Request, background_tasks: BackgroundTasks):
|
||||||
@@ -21,11 +21,10 @@ async def receive_webhook(request: Request, background_tasks: BackgroundTasks):
|
|||||||
"""
|
"""
|
||||||
# 1. Verify Secret (Basic Security)
|
# 1. Verify Secret (Basic Security)
|
||||||
# SuperOffice puts signature in headers, but for custom webhook we might just use query param or header
|
# SuperOffice puts signature in headers, but for custom webhook we might just use query param or header
|
||||||
# Let's assume for now a shared secret in header 'X-SuperOffice-Signature' or similar
|
|
||||||
# Or simply a secret in the URL: /webhook?token=...
|
# Or simply a secret in the URL: /webhook?token=...
|
||||||
|
|
||||||
token = request.query_params.get("token")
|
token = request.query_params.get("token")
|
||||||
if token != WEBHOOK_SECRET:
|
if token != WEBHOOK_TOKEN:
|
||||||
logger.warning(f"Invalid webhook token attempt: {token}")
|
logger.warning(f"Invalid webhook token attempt: {token}")
|
||||||
raise HTTPException(403, "Invalid Token")
|
raise HTTPException(403, "Invalid Token")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user