Temporal.io Worker Interceptor for Predicate Authority Zero-Trust authorization
Project description
predicate-temporal
Temporal.io Worker Interceptor for Predicate Authority Zero-Trust authorization.
This package provides a pre-execution security gate for all Temporal Activities, enforcing cryptographic authorization mandates before any activity code runs.
Prerequisites
This package requires the Predicate Authority Sidecar daemon to be running. The sidecar is a lightweight Rust binary that handles policy evaluation and mandate signing.
| Resource | Link |
|---|---|
| Sidecar Repository | github.com/PredicateSystems/predicate-authority-sidecar |
| Download Binaries | Latest Releases |
| License | MIT / Apache 2.0 |
Quick Sidecar Setup
# Download the latest release for your platform
# Linux x64, macOS x64/ARM64, Windows x64 available
# Extract and run
tar -xzf predicate-authorityd-*.tar.gz
chmod +x predicate-authorityd
# Start with a policy file
./predicate-authorityd --port 8787 --policy-file policy.json
Installation
pip install predicate-temporal
Quick Start
from temporalio.worker import Worker
from predicate_temporal import PredicateInterceptor
from predicate_authority import AuthorityClient
# Initialize the Predicate Authority client
ctx = AuthorityClient.from_env()
# Create the interceptor
interceptor = PredicateInterceptor(
authority_client=ctx.client,
principal="temporal-worker",
)
# Create worker with the interceptor
worker = Worker(
client=temporal_client,
task_queue="my-task-queue",
workflows=[MyWorkflow],
activities=[my_activity],
interceptors=[interceptor],
)
How It Works
The interceptor sits in the Temporal activity execution pipeline:
- Temporal dispatches an activity to your worker
- Before the activity code runs, the interceptor extracts:
- Activity name (action)
- Activity arguments (context)
- The interceptor calls
AuthorityClient.authorize()to request a mandate - If denied: raises
PermissionError- activity never executes - If approved: activity proceeds normally
This ensures that no untrusted code or payload reaches your OS until it has been cryptographically authorized.
Configuration
Environment Variables
Set these environment variables for the Authority client:
export PREDICATE_AUTHORITY_POLICY_FILE=/path/to/policy.json
export PREDICATE_AUTHORITY_SIGNING_KEY=your-secret-key
export PREDICATE_AUTHORITY_MANDATE_TTL_SECONDS=300
Policy File
Create a policy file that defines allowed activities:
{
"rules": [
{
"name": "allow-safe-activities",
"effect": "allow",
"principals": ["temporal-worker"],
"actions": ["process_order", "send_notification"],
"resources": ["*"]
},
{
"name": "deny-dangerous-activities",
"effect": "deny",
"principals": ["*"],
"actions": ["delete_*", "admin_*"],
"resources": ["*"]
}
]
}
API Reference
PredicateInterceptor
PredicateInterceptor(
authority_client: AuthorityClient,
principal: str = "temporal-worker",
tenant_id: str | None = None,
session_id: str | None = None,
)
Parameters:
authority_client: The Predicate Authority client instanceprincipal: Principal ID used for authorization requests (default: "temporal-worker")tenant_id: Optional tenant ID for multi-tenant setupssession_id: Optional session ID for request correlation
PredicateActivityInterceptor
The inbound interceptor that performs the actual authorization check. Created automatically by PredicateInterceptor.
Error Handling
When authorization is denied, the interceptor raises a PermissionError:
try:
await workflow.execute_activity(
dangerous_activity,
args,
start_to_close_timeout=timedelta(seconds=30),
)
except ActivityError as e:
if isinstance(e.cause, ApplicationError):
# Handle authorization denial
print(f"Activity blocked: {e.cause.message}")
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src
# Linting
ruff check src tests
ruff format src tests
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file predicate_temporal-0.1.0.tar.gz.
File metadata
- Download URL: predicate_temporal-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d015ab24fec651e292200debf7c2d0da715368806afb282b87910ae3e6802a44
|
|
| MD5 |
2776b49d2f9f083e90f776d6ec7b7036
|
|
| BLAKE2b-256 |
34776e3ecb88032f68fa22fa8a90245e11d27cdcc7f0f42f6b8c04e4aee7dbf2
|
Provenance
The following attestation bundles were made for predicate_temporal-0.1.0.tar.gz:
Publisher:
release.yml on PredicateSystems/temporal-predicate-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predicate_temporal-0.1.0.tar.gz -
Subject digest:
d015ab24fec651e292200debf7c2d0da715368806afb282b87910ae3e6802a44 - Sigstore transparency entry: 975918280
- Sigstore integration time:
-
Permalink:
PredicateSystems/temporal-predicate-py@5d6a08284d63fd6b34adf60303f6e7bd3eb87aae -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PredicateSystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d6a08284d63fd6b34adf60303f6e7bd3eb87aae -
Trigger Event:
push
-
Statement type:
File details
Details for the file predicate_temporal-0.1.0-py3-none-any.whl.
File metadata
- Download URL: predicate_temporal-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f16d312680ae2f57ca809a1fa0e7c83ddf13a466b1c62fcd1313367aa6a09064
|
|
| MD5 |
509f9d5f9075b82756ec07d989fd067e
|
|
| BLAKE2b-256 |
66f2ebe8b99c92bc0223dcb9c5c81d8442c145281f0cba296a4a4c490a9b6b7a
|
Provenance
The following attestation bundles were made for predicate_temporal-0.1.0-py3-none-any.whl:
Publisher:
release.yml on PredicateSystems/temporal-predicate-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predicate_temporal-0.1.0-py3-none-any.whl -
Subject digest:
f16d312680ae2f57ca809a1fa0e7c83ddf13a466b1c62fcd1313367aa6a09064 - Sigstore transparency entry: 975918290
- Sigstore integration time:
-
Permalink:
PredicateSystems/temporal-predicate-py@5d6a08284d63fd6b34adf60303f6e7bd3eb87aae -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PredicateSystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d6a08284d63fd6b34adf60303f6e7bd3eb87aae -
Trigger Event:
push
-
Statement type: