feat(python-sdk): support sandboxd bearer authentication

Merged
QU
1mo ago
+476-19

What this PR does / why we need it:

The Python SDK cannot authenticate command and file operations against a token-protected sandboxd.

This PR adds optional auth_token to SandboxdPodTunnelConnectionConfig and SandboxdInClusterConnectionConfig, aligned with the TypeScript SDK's sandboxd.authToken:

  • Sync and async clients attach bearer credentials to REST requests and use channel interceptors for unary/streaming gRPC calls.
  • Tokens must be nonempty printable ASCII strings without spaces. SecretStr storage and validation-error redaction prevent accidental exposure.
  • Configured tokens take precedence over caller-supplied Authorization headers and implicit .netrc credentials.

Includes regression tests and usage/API documentation. Request behavior remains unchanged when no token is configured.

Validation
  • make all and git diff --check passed.
  • Python SDK: 775 tests and 54 subtests passed; mypy passed for all 33 source files.
  • Hugo preview: authentication documentation rendered and reviewed.
  • Token-focused Kubernetes E2E: 18 scenarios passed across Pod tunnels, in-cluster Services, and Pod IPs, with sync/async clients and valid/invalid/missing tokens.

Which issue(s) this PR is related to:

Ref #1785 — SDK alignment.

Related implementations: sandboxd authentication #1895 and TypeScript SDK authentication #1942.

Release Note

The Python SDK now supports optional auth_token for sandboxd connections in sync and async clients, covering REST requests and unary/streaming gRPC calls.

Summary by CodeRabbit

  • New Features
    • Python clients can now authenticate to sandboxd over REST and gRPC with an optional bearer token, including after reconnects. Tokens are validated and kept hidden in configuration errors. Without a token, existing behavior is unchanged.
  • Documentation
    • Updated the Python client documentation with token setup and security details, including the need to configure a matching sandboxd token and that authentication does not enable TLS.