langchain-trigger-server 0.2.6rc3__tar.gz → 0.2.6rc4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of langchain-trigger-server might be problematic. Click here for more details.
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/PKG-INFO +1 -1
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/app.py +80 -7
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/pyproject.toml +1 -1
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/.github/workflows/release.yml +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/.vscode/settings.json +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/README.md +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/__init__.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/auth/__init__.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/auth/slack_hmac.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/core.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/cron_manager.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/database/__init__.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/database/interface.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/database/supabase.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/decorators.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/triggers/__init__.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/triggers/cron_trigger.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/test_framework.py +0 -0
- {langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-trigger-server
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6rc4
|
|
4
4
|
Summary: Generic event-driven triggers framework
|
|
5
5
|
Project-URL: Homepage, https://github.com/langchain-ai/open-agent-platform
|
|
6
6
|
Project-URL: Repository, https://github.com/langchain-ai/open-agent-platform
|
{langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/app.py
RENAMED
|
@@ -492,15 +492,21 @@ class TriggerServer:
|
|
|
492
492
|
) -> Dict[str, Any]:
|
|
493
493
|
"""Handle an incoming request with a handler function."""
|
|
494
494
|
try:
|
|
495
|
-
# Slack webhook authentication
|
|
496
|
-
# Check if this is a Slack trigger that requires HMAC signature verification
|
|
497
|
-
if self._is_slack_trigger(trigger):
|
|
498
|
-
await self._verify_slack_webhook_auth(request)
|
|
499
|
-
|
|
500
|
-
# Parse request data
|
|
501
495
|
if request.method == "POST":
|
|
502
496
|
if request.headers.get("content-type", "").startswith("application/json"):
|
|
503
|
-
|
|
497
|
+
# Read body once for both auth and parsing
|
|
498
|
+
body_bytes = await request.body()
|
|
499
|
+
body_str = body_bytes.decode("utf-8")
|
|
500
|
+
|
|
501
|
+
if self._is_slack_trigger(trigger):
|
|
502
|
+
await self._verify_slack_webhook_auth_with_body(request, body_str)
|
|
503
|
+
|
|
504
|
+
import json
|
|
505
|
+
payload = json.loads(body_str)
|
|
506
|
+
|
|
507
|
+
if payload.get("type") == "url_verification" and "challenge" in payload:
|
|
508
|
+
logger.info(f"Responding to Slack URL verification challenge")
|
|
509
|
+
return {"challenge": payload["challenge"]}
|
|
504
510
|
else:
|
|
505
511
|
# Handle form data or other content types
|
|
506
512
|
body = await request.body()
|
|
@@ -678,6 +684,73 @@ class TriggerServer:
|
|
|
678
684
|
detail=f"Authentication error: {str(e)}"
|
|
679
685
|
)
|
|
680
686
|
|
|
687
|
+
async def _verify_slack_webhook_auth_with_body(self, request: Request, body_str: str) -> None:
|
|
688
|
+
"""Verify Slack HMAC signature for webhook requests using pre-read body.
|
|
689
|
+
|
|
690
|
+
Slack uses HMAC-SHA256 signatures to verify webhook authenticity.
|
|
691
|
+
The signature is computed from the timestamp, body, and signing secret.
|
|
692
|
+
|
|
693
|
+
Args:
|
|
694
|
+
request: The FastAPI request object
|
|
695
|
+
body_str: The request body as a string (already read)
|
|
696
|
+
|
|
697
|
+
Raises:
|
|
698
|
+
HTTPException: If authentication fails
|
|
699
|
+
"""
|
|
700
|
+
try:
|
|
701
|
+
signing_secret = get_slack_signing_secret()
|
|
702
|
+
if not signing_secret:
|
|
703
|
+
logger.error("SLACK_SIGNING_SECRET environment variable not set")
|
|
704
|
+
raise HTTPException(
|
|
705
|
+
status_code=500,
|
|
706
|
+
detail="Slack signing secret not configured on server"
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
headers_dict = dict(request.headers)
|
|
710
|
+
signature, timestamp = extract_slack_headers(headers_dict)
|
|
711
|
+
|
|
712
|
+
if not signature:
|
|
713
|
+
logger.error("Missing X-Slack-Signature header")
|
|
714
|
+
raise HTTPException(
|
|
715
|
+
status_code=401,
|
|
716
|
+
detail="Missing X-Slack-Signature header. Slack webhooks require signature verification."
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
if not timestamp:
|
|
720
|
+
logger.error("Missing X-Slack-Request-Timestamp header")
|
|
721
|
+
raise HTTPException(
|
|
722
|
+
status_code=401,
|
|
723
|
+
detail="Missing X-Slack-Request-Timestamp header. Slack webhooks require timestamp."
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
try:
|
|
727
|
+
verify_slack_signature(
|
|
728
|
+
signing_secret=signing_secret,
|
|
729
|
+
timestamp=timestamp,
|
|
730
|
+
body=body_str,
|
|
731
|
+
signature=signature
|
|
732
|
+
)
|
|
733
|
+
logger.info(f"Successfully verified Slack webhook signature. Timestamp: {timestamp}")
|
|
734
|
+
except SlackSignatureVerificationError as e:
|
|
735
|
+
logger.error(f"Slack signature verification failed: {e}")
|
|
736
|
+
raise HTTPException(
|
|
737
|
+
status_code=401,
|
|
738
|
+
detail=f"Slack signature verification failed: {str(e)}"
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
# Store verification info in request state
|
|
742
|
+
request.state.slack_verified = True
|
|
743
|
+
request.state.slack_timestamp = timestamp
|
|
744
|
+
|
|
745
|
+
except HTTPException:
|
|
746
|
+
raise
|
|
747
|
+
except Exception as e:
|
|
748
|
+
logger.error(f"Unexpected error during Slack webhook authentication: {e}")
|
|
749
|
+
raise HTTPException(
|
|
750
|
+
status_code=500,
|
|
751
|
+
detail=f"Authentication error: {str(e)}"
|
|
752
|
+
)
|
|
753
|
+
|
|
681
754
|
def get_app(self) -> FastAPI:
|
|
682
755
|
"""Get the FastAPI app instance."""
|
|
683
756
|
return self.app
|
|
File without changes
|
{langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/.vscode/settings.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_trigger_server-0.2.6rc3 → langchain_trigger_server-0.2.6rc4}/langchain_triggers/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|