Skip to content

Commit e2a3603

Browse files
committed
Fix verification bypassing in webhook
1 parent 302b37e commit e2a3603

File tree

1 file changed

+13
-8
lines changed
  • langchain-interpreter/src/afm_cli/interfaces

1 file changed

+13
-8
lines changed

langchain-interpreter/src/afm_cli/interfaces/webhook.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,19 @@ async def websub_verification(
306306
if hub_mode in ("subscribe", "unsubscribe"):
307307
# If we have a subscriber, verify the topic matches
308308
if websub_subscriber is not None:
309-
if hub_topic != websub_subscriber.topic:
310-
raise HTTPException(status_code=404, detail="Topic mismatch")
311-
# Mark as verified on successful verification
312-
if hub_mode == "subscribe":
313-
websub_subscriber._verified = True
314-
elif websub_subscriber is None and hasattr(
315-
request.app.state, "websub_subscriber"
316-
):
309+
# Use subscriber's verification logic
310+
challenge = websub_subscriber.verify_challenge(
311+
hub_mode,
312+
hub_topic,
313+
hub_challenge,
314+
lease_seconds=hub_lease_seconds,
315+
)
316+
if challenge:
317+
return PlainTextResponse(content=challenge)
318+
# Verification failed (e.g. topic mismatch)
319+
raise HTTPException(status_code=404, detail="Verification failed")
320+
321+
elif hasattr(request.app.state, "websub_subscriber"):
317322
# Subscriber was explicitly set to None - reject verification
318323
raise HTTPException(status_code=404, detail="No subscriber configured")
319324

0 commit comments

Comments
 (0)