Skip to main content

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.

PyPI Python License


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[azure]   # Azure Blob backend (AAD User Delegation SAS)
pip install pymayfly[gcp]     # GCS backend (impersonation + downscoped tokens)
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 / S3 TTL only (900s min) FedRAMP / HIPAA
GCSBroker pymayfly[gcp] GCP / GCS TTL only (15 min) FedRAMP / HIPAA
AzureBlobBroker pymayfly[azure] Azure / Blob Storage TTL only (15 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 or Supabase 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


Download files

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

Source Distribution

pymayfly-0.2.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

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

pymayfly-0.2.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file pymayfly-0.2.0.tar.gz.

File metadata

  • Download URL: pymayfly-0.2.0.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymayfly-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ace3d52c4faaab00f70d9062719996847b32743598c1c9146aa097f28a899058
MD5 9d74d9a5e9b888989ff0e106374c9ab2
BLAKE2b-256 6c3e29b20fb2c5464930b81e879da7a78ae3c1f73db9af1f4ecfa5bf47e14db2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymayfly-0.2.0.tar.gz:

Publisher: release.yml on deterministic-systems-lab/pymayfly

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

File details

Details for the file pymayfly-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pymayfly-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymayfly-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5376b2022fd035c723e83673ce0a74da477858a7952442676588c748d70483f5
MD5 394733debf759398a3ffea14e847ada2
BLAKE2b-256 7caf907cbb001bbd016e7ed87bf5fab53489356ea032d46ffa4f70d1e3c10267

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymayfly-0.2.0-py3-none-any.whl:

Publisher: release.yml on deterministic-systems-lab/pymayfly

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