Skip to main content

Encryption for the Inngest SDK

Project description

Inngest Python SDK: Encryption

This package provides encryption for the Inngest Python SDK.

Usage

Setting encryption middleware on the client will turn on encryption for events and steps in all functions:

import inngest
from inngest_encryption import EncryptionMiddleware

inngest.Inngest(
    name="my-app",
    encryption_key="my-encryption-key",
    middleware=[EncryptionMiddleware.factory("my-secret-key")],
)

When sending events or invoking functions, only the encrypted field will be encrypted:

await step.send_event(
    "my-step",
    inngest.Event(
        data={
            # Everything in this field will be encrypted.
            "encrypted": {
                "phone": "867-5309",
            },

            # Not encrypted.
            "user_id": "abc123",
        },
        name="my-event",
    ),
)

await step.invoke(
    "invoke",
    function=child_fn_async,
    data={
        # Everything in this field will be encrypted.
        "encrypted": {
            "phone": "867-5309",
        },

        # Not encrypted.
        "user_id": "abc123",
    },
)

[!NOTE]
Only a portion of the event data is encrypted because that allows for control flow settings (e.g. concurrency key) to work. Since the Inngest server receives encrypted data, it can't perform control flow on values that are encrypted.

The entire step.run output is encrypted:

def _my_step() -> dict[str, object]:
    # Encrypted when sending back to the Inngest server.
    return {"msg": "hello"}

output = await step.run("my-step", _my_step)

# Decrypted within this function.
print(output)

Key rotation

When rotating the encryption key, you may still have active functions runs whose data is encrypted with the old key. To decrypt these, you can use the fallback_decryption_keys option:

inngest.Inngest(
    name="my-app",
    encryption_key="my-encryption-key",
    middleware=[
        EncryptionMiddleware.factory(
            "new-secret-key",
            fallback_decryption_keys=["old-secret-key"],
        ),
    ],
)

If decryption fails with the new key, the encryption middleware will fall back to the old 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

inngest_encryption-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

inngest_encryption-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file inngest_encryption-0.1.0.tar.gz.

File metadata

  • Download URL: inngest_encryption-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for inngest_encryption-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70bfe640a7f7e479c955dd34269e3f9c3154fa83c0a9d68b44563b2db1cf4300
MD5 06fc7f7010196d40f2001aa24c714626
BLAKE2b-256 09e947ac0f9960989485baafeb0a32a0796c25340a29106cb3d6f34919734048

See more details on using hashes here.

Provenance

The following attestation bundles were made for inngest_encryption-0.1.0.tar.gz:

Publisher: inngest_encryption.yml on inngest/inngest-py

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

File details

Details for the file inngest_encryption-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for inngest_encryption-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb8efdc602e14dc606415b2b1d333099ec0afd4efade7ec4ed971bc88c26bf9
MD5 5a62eef7a2f9e7ca7d40d596bc3187e6
BLAKE2b-256 d372f00f3d1f59ac994eec1a8aa7861843dc2dbd0d0fe6359c7792f68b2223c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for inngest_encryption-0.1.0-py3-none-any.whl:

Publisher: inngest_encryption.yml on inngest/inngest-py

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