Identity-Per-Transaction: ephemeral, transaction-scoped credentials for regulated data pipelines
Project description
pymayfly
Identity-Per-Transaction for regulated data pipelines.
Like a mayfly, these credentials live for exactly one transaction.
The Problem
Most enterprise "zero trust" implementations authenticate once and trust indefinitely. A single compromised credential — a leaked IAM role, a stolen service account key, a reused session token — exposes your entire data lake for hours or days.
The Solution
Identity-Per-Transaction (IPT) issues credentials scoped to exactly one resource for exactly one transaction. A compromised credential exposes one object. When that object is deleted post-processing, the credential points at nothing for the remainder of its TTL.
Traditional model: compromised key → entire data lake
IPT model: compromised key → single S3 object key (now deleted)
Install
pip install pymayfly[aws] # AWS STS backend (FedRAMP-suitable)
pip install pymayfly # core only — bring your own provider
Quickstart
Decorator (AWS Lambda)
import boto3
from pymayfly import IPTEnforcer, AWSSTSBroker, FileAuditLedger
enforcer = IPTEnforcer(
broker=AWSSTSBroker(role_arn="arn:aws:iam::123456789012:role/IPTProcessor"),
ledger=FileAuditLedger("/var/log/mayfly/audit.jsonl"),
)
@enforcer.protect(
resource_from=lambda e: (
f"arn:aws:s3:::{e['Records'][0]['s3']['bucket']['name']}"
f"/{e['Records'][0]['s3']['object']['key']}"
),
action="read",
)
def handler(event, context, *, creds):
s3 = boto3.client(
"s3",
aws_access_key_id=creds.token["AccessKeyId"],
aws_secret_access_key=creds.token["SecretAccessKey"],
aws_session_token=creds.token["SessionToken"],
)
record = event["Records"][0]
bucket = record["s3"]["bucket"]["name"]
key = record["s3"]["object"]["key"]
data = s3.get_object(Bucket=bucket, Key=key)
# process, de-identify, write to clean zone
# delete source object → credential now points at nothing
Context Manager
from pymayfly import transaction_scope, AWSSTSBroker
broker = AWSSTSBroker(role_arn="arn:aws:iam::123456789012:role/IPTProcessor")
with transaction_scope(
broker,
resource="arn:aws:s3:::bucket/patient-001.parquet",
action="read",
) as creds:
# creds scoped to exactly this object
process(creds)
# creds revoked (or expired) here
Providers
| Provider | Install | Platform | Revocation | Regulated Use |
|---|---|---|---|---|
AWSSTSBroker |
pymayfly[aws] |
AWS | TTL only (900s min) | FedRAMP / HIPAA |
VaultBroker |
Planned for 0.2.0 | Any | Explicit | Any |
SupabaseJWTBroker |
Planned for 0.2.0 | Postgres | Blocklist | Dev / test only |
Security Properties
| Metric | Traditional (bucket-wide role) | IPT |
|---|---|---|
| Blast radius | Entire data lake | Single object |
| Credential lifetime | Days / weeks | 900s |
| Post-deletion access | Credential still valid | Credential points at nothing |
| Audit granularity | Session-level | Transaction-level |
For a 1M-object data lake: blast radius reduced by 99.999%.
Implementing a Custom Provider
Subclass IdentityBroker and implement three methods:
from pymayfly import IdentityBroker, EphemeralCredential
class MyBroker(IdentityBroker):
def issue(self, transaction_id, resource, action) -> EphemeralCredential:
...
def revoke(self, credential) -> None:
...
def blast_radius(self, credential) -> str:
...
See docs/providers.md for a provider walkthrough and
pymayfly/providers/aws_sts.py for a complete implementation.
Research
This library implements the Identity-Per-Transaction protocol described in:
McKinnon, T. (2026). Zero-Trust Data Engineering: A Reference Architecture for Serverless, FedRAMP-High Healthcare Pipelines. IEEE BigDataSecurity 2026. TechRxiv preprint
Contributing
Issues and PRs welcome. See CONTRIBUTING.md.
Provider contributions especially encouraged — if you implement a Vault, Azure, or GCP backend, open a PR. Use the new provider issue template.
License
Apache 2.0. See LICENSE.
Built and maintained by Deterministic Systems Lab.
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 pymayfly-0.1.0.tar.gz.
File metadata
- Download URL: pymayfly-0.1.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06c707aec60887ea7ee68ad6ef6e581ef3986e5b5fa9c79116f078f242120feb
|
|
| MD5 |
8f78a5fca85dc6bb5c0abc6debb086c9
|
|
| BLAKE2b-256 |
e6ce611e89aefc6b1a9d75f545b453d93018f95cc7a9e4c0c358cf321d19b16e
|
File details
Details for the file pymayfly-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymayfly-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5921cf770b9d73fcc97bffa34229c2d52387678c56fff23c11542f1096f87f89
|
|
| MD5 |
1d4a89682567d88cace60474b101c226
|
|
| BLAKE2b-256 |
a8c4991dd883247afd1401ea6abeee6ce9513e772914c189a325156612c7aae9
|