fix: authorize flow management, gate runs, token-gate callbacks, strict tenants
This commit is contained in:
parent
cfcf0e8bd6
commit
94e5e53092
21 changed files with 662 additions and 160 deletions
|
|
@ -302,6 +302,11 @@ class EnvelopeComponent(Component):
|
|||
name="continuation",
|
||||
method="get_continuation",
|
||||
),
|
||||
Output(
|
||||
display_name="Callback Token",
|
||||
name="callback_token",
|
||||
method="get_callback_token",
|
||||
),
|
||||
]
|
||||
|
||||
def _text(self, value) -> str:
|
||||
|
|
@ -333,6 +338,9 @@ class EnvelopeComponent(Component):
|
|||
def get_continuation(self) -> Message:
|
||||
value = self._env().get("continuation_flow_id")
|
||||
return Message(text=str(value) if value else "")
|
||||
|
||||
def get_callback_token(self) -> Message:
|
||||
return Message(text=str(self._env().get("callback_token", "")))
|
||||
"""
|
||||
|
||||
APPROVAL_CALLBACK_CODE = """from lfx.custom import Component
|
||||
|
|
@ -348,6 +356,10 @@ class ApprovalCallbackComponent(Component):
|
|||
MessageTextInput(name="trigger", display_name="Trigger"),
|
||||
MessageTextInput(name="run_id", display_name="Run ID"),
|
||||
MessageTextInput(name="callback_url", display_name="Callback URL"),
|
||||
MessageTextInput(
|
||||
name="callback_token",
|
||||
display_name="Callback Token",
|
||||
),
|
||||
MessageTextInput(
|
||||
name="continuation_flow_id",
|
||||
display_name="Continuation Flow ID",
|
||||
|
|
@ -384,8 +396,9 @@ class ApprovalCallbackComponent(Component):
|
|||
"payload": {"verdict": trigger, "facts": facts},
|
||||
"continuation_flow_id": self._text(self.continuation_flow_id) or None,
|
||||
}
|
||||
headers = {"X-Callback-Token": self._text(self.callback_token)}
|
||||
try:
|
||||
response = httpx.post(url, json=body, timeout=10.0)
|
||||
response = httpx.post(url, json=body, headers=headers, timeout=10.0)
|
||||
response.raise_for_status()
|
||||
except Exception as exc:
|
||||
return Message(text=f"CALLBACK_FAILED: {exc}")
|
||||
|
|
@ -487,6 +500,7 @@ def build_approval_handoff() -> dict:
|
|||
edge(router, "true_result", callback, "trigger"),
|
||||
edge(envelope, "run_id", callback, "run_id"),
|
||||
edge(envelope, "callback_url", callback, "callback_url"),
|
||||
edge(envelope, "callback_token", callback, "callback_token"),
|
||||
edge(envelope, "continuation", callback, "continuation_flow_id"),
|
||||
edge(envelope, "payload", callback, "facts"),
|
||||
edge(callback, "result", out_pending, "input_value"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue