mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-16 09:38:41 +00:00
Sandbox is an execution environment, not a named resource: multiple tools
(bash, read_file, write_file, glob, grep, ...) depend on it, all funneled
through ensure_sandbox_initialized / ensure_sandbox_initialized_async. Gate
the single acquisition entry point (single source of truth) instead of
maintaining a sandbox-tool-name set in middleware:
- authorize_sandbox_execution helper (authz/sandbox_authz.py) checks
authorize("sandbox", "execute", target="*") — a binary judgment
(can this role use the sandbox at all); RBAC allow:"*"/true permits,
allow:[]/false denies.
- lazy path: ensure_sandbox_initialized (+ async) calls the gate before
provider.acquire.
- eager path: SandboxMiddleware.before_agent / abefore_agent call the gate
before _acquire_sandbox.
- deny raises SandboxAuthorizationError (SandboxError subclass) which
propagates through tool execution as a friendly ToolMessage (RFC §9:
'not a crash').
- authorization.enabled: false is a no-op everywhere; provider errors
follow fail_closed (deny) / fail_open (allow).
12 tests in tests/test_sandbox_authorization.py cover disabled/allow/deny/
deny-via-bool/no-policy-unrestricted/provider-error-fail-closed/open/
internal-caller + ensure_sandbox_initialized deny (never acquires) and
allow (acquires) integration paths.
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""Pluggable fine-grained authorization (resource-level RBAC and beyond)."""
|
|
|
|
from deerflow.authz.adapter import GuardrailAuthorizationAdapter
|
|
from deerflow.authz.enforcement import filter_tools_by_authorization
|
|
from deerflow.authz.principal import build_principal_from_context, normalize_authz_attributes
|
|
from deerflow.authz.provider import AuthorizationProvider, AuthzDecision, AuthzReason, AuthzRequest, Principal
|
|
from deerflow.authz.rbac import RbacAuthorizationProvider
|
|
from deerflow.authz.runtime import resolve_authorization_provider
|
|
from deerflow.authz.sandbox_authz import authorize_sandbox_execution
|
|
from deerflow.authz.tool_filter import apply_tool_authorization
|
|
|
|
__all__ = [
|
|
"AuthzDecision",
|
|
"AuthzReason",
|
|
"AuthzRequest",
|
|
"AuthorizationProvider",
|
|
"GuardrailAuthorizationAdapter",
|
|
"Principal",
|
|
"RbacAuthorizationProvider",
|
|
"apply_tool_authorization",
|
|
"authorize_sandbox_execution",
|
|
"build_principal_from_context",
|
|
"filter_tools_by_authorization",
|
|
"normalize_authz_attributes",
|
|
"resolve_authorization_provider",
|
|
]
|