Skip to main content

Python SDK foundation for TrustPlane Auth request material and local Ed25519 signing

Project description

TrustPlane Auth SDK for Python

Caller-side Python SDK for TrustPlane Auth.

The API supports CLI-compatible Ed25519 keys and passports, transcript-v1 signing, active Control key-grant profiles, arbitrary HTTP methods, TA-G1 public auto-enrollment, and broker IPC v1.

Install

Install a verified release with an explicit package version:

python -m pip install trustplane-auth-sdk==0.2.3

Signed request from a key grant

from trustplane_auth import (
    ProtectedClient,
    SigningProfile,
    private_key_from_base64url,
)

profile = SigningProfile.from_control(control_signing_profile_json)
private_key = private_key_from_base64url(private_key_file_contents.strip())
client = ProtectedClient(profile, private_key)

response = client.request(
    profile.method,
    "/orders/123?expand=items",
    headers={"Accept": "application/json"},
)

Each request receives a fresh short-lived passport/JTI, nonce, canonical body/query/header digest, and proof. The client rejects a method or path outside the active profile, including sibling-prefix mistakes. Parameterized profiles require a concrete path (/orders/123, not /orders/{id}); encoded or ambiguous paths fail closed, query-only targets retain a literal profile path, and redirects are not followed with TrustPlane credentials.

Auto-enrollment

from trustplane_auth import EnrollmentClient, EnrollmentOptions, jwt_enrollment_proof

result = EnrollmentClient().enroll(
    EnrollmentOptions(
        control_url="https://control.example",
        enrollment_policy_ref="enrpol_...",
        provider="kubernetes_service_account_oidc",
        private_key=private_key,
        proof_provider=lambda challenge: jwt_enrollment_proof(
            obtain_audience_bound_token(challenge.expected_audience)
        ),
    )
)

The SDK validates Control's immutable source revision, Azure proof mode when applicable, and required encoding before invoking the proof callback. Helpers also build AWS IID and Azure IMDS attested-document proof values. The safe result never contains proof, key, nonce, signature, or poll capability material. Enrollment requires HTTPS.

Provider credential acquisition stays in the application callback so it can use the host's projected token, CI, SPIFFE, or cloud metadata client. The SDK owns the complete Control protocol. Once a submission is accepted, a polling deadline returns a safe pending result with the request ID instead of resubmitting the proof.

Workload profile resolution

After Control activates the enrolled key and the corresponding target configuration is acknowledged, resolve the key's own public profiles with the same local key. This path needs no Control Read Token or manually supplied profile:

from trustplane_auth import WorkloadProfileClient, WorkloadProfileOptions

resolution = WorkloadProfileClient().resolve(
    WorkloadProfileOptions(
        control_url="https://control.example",
        enrollment_policy_ref="enrpol_...",
        key_id=enrollment_result.key_id,
        private_key=private_key,
    )
)

if resolution.state == "active":
    profile = resolution.select_profile("GET", "/api/customers")
    protected_client = ProtectedClient(profile.to_signing_profile(), private_key)

The client signs Control's short-lived, single-use challenge with the local Ed25519 key and validates the key/policy binding, expiry boundaries, and public response schema. pending, inactive_key, and unavailable are stable results; only inactive_key is a reason to enroll a replacement key. Local selection rejects zero or ambiguous method/path matches. Active profile caching stops at the earliest key expiry, profile expiry, or server refresh boundary.

Broker mode

build_broker_request, BrokerClient.issue, and broker_headers provide the caller side of broker IPC v1 over a Unix socket. This package does not include the broker runtime.

Scope boundary

This package does not embed a verifier, adapter, policy engine, SPIFFE issuer, deployment logic, Control administrative API, or CLI-only bundle/local-demo commands.

Raw local signing is software-only. Stronger signer classes must be fulfilled by an appropriate broker or signer; they are never simulated with an exportable key.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trustplane_auth_sdk-0.2.3.tar.gz (45.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trustplane_auth_sdk-0.2.3-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file trustplane_auth_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: trustplane_auth_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 45.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for trustplane_auth_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 07d9af56cdf488bba8a3bfceee0c108171faf022141b977c06081d00b86d5c02
MD5 66d29bb70256e3b71dfbd38d2a70e218
BLAKE2b-256 aa591a84d05f1fa7a9664012c92b67263250c1111a1a9634328168ce6d203642

See more details on using hashes here.

Provenance

The following attestation bundles were made for trustplane_auth_sdk-0.2.3.tar.gz:

Publisher: release-pypi.yml on trustplane-dev/trustplane-auth-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trustplane_auth_sdk-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for trustplane_auth_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e081853900761d37975cdae44b407b349d957dfa47cb0ba600c8c1742f018e7
MD5 76ba4dfbe2468b3437bed401dd0c8a06
BLAKE2b-256 ab2b96f2ee1384ae7ef3091d0a5cf4795977874ad953de5d4996f113f70d455e

See more details on using hashes here.

Provenance

The following attestation bundles were made for trustplane_auth_sdk-0.2.3-py3-none-any.whl:

Publisher: release-pypi.yml on trustplane-dev/trustplane-auth-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page