Skip to main content

Ziggy loves python

Python SDK for OpenZiti

Discourse GitHub Stars Downloads License

Getting StartedExamplesSupportContributingLicense

The Python SDK for OpenZiti is a library that enables you to integrate zero trust network connectivity into your Python applications, and establish secure connections with remote network resources over an OpenZiti network. The SDK also simplifies the process of adding secure, zero-trust network connectivity built into your Python application. It's so simple that it can be done in just two lines of code!

OpenZiti is an open-source project that provides secure, zero-trust networking for applications running on any platform.

More specifically, the SDK allows you to integrate zero trust at the application level. This means your data is never exposed outside the application environment providing you with end-to-end encryption for ultimate security. See other zero trust models here.

Zero-trust-application-access

Getting Started

See the get started guide to learn how to deploy your own overlay.

Or, you can try CloudZiti for free, check out more here.

Installing the SDK

The Python SDK for OpenZiti is distributed via the Python Package Index (PyPI) and can be installed using pip package manager.

pip install openziti

Using Ziti Python SDK

With just two lines of code, you can turn your plain old web server into a secure, zero-trust embedded application. Below is an example of just how simple it is to get started.

Provide a hostname, and port for your application, a simple monkey patch, and you're ready to go. You don't even need to know what a monkey patch is! However, if you're interested in what a monkey patch is, expand the block below.

What is Monkey Patching?

Monkey patching allows developers to modify functionality for code even when they may not have access to the original source code. Because Python has a dynamic object model allowing developers to modify objects at runtime. Monkey patching allows developers to point a function call to any function they want. We can even implement our own function that doesn't exist in the source code.

The way this Python SDK uses monkey patching is to override existing functionality in socket handling by the socket module.

Taking a look at the code below, the key lines are the last two. You can see how, for each monkey patched function, we're telling that function call on the sock object to be directed to the function held in _patch_methods. Therefore, this SDK can be used on any application that doesn't manage its own sockets.

def __init__(self, **kwargs):
    self.orig_socket = sock.socket
    sock.socket = _patchedSocket(kwargs)
    self.orig_methods = {m: sock.__dict__[m] for m, _ in
                         _patch_methods.items()}
    for m_name, _ in _patch_methods.items():
        sock.__dict__[m_name] = _patch_methods[m_name]
cfg = dict(ztx=openziti.load('/path/to/identity.json'), service="name-of-ziti-service")
openziti.monkeypatch(bindings={('127.0.0.1', 8000): cfg})

Or try our decorator pattern with a function annotation

@openziti.zitify(bindings={('127.0.0.1', 18080): {'ztx': '/path/to/identity.json', 'service': 'name-of-ziti-service'}})
def yourFunction():

The binding dictionary configures what happens when the code tries to open a server socket. Standard network addresses are mapped to ziti service configurations. For example, with his configuration

bindings = {
   ('0.0.0.0', 8080): { 'ztx': 'my-identity.json', 'service':'my-service' }
}

when application opens a server socket and binds to address 0.0.0.0:8080 it will actually bind to the ziti service named my-service.

Binding addresses can be specified with tuples, strings, or ints(ports). ('0.0.0.0', 8080), '0.0.0.0:8080', ':8080', 8080 are all considered and treated the same.

Examples

Try it out yourself with one of our examples

Support

Looking for Help?

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.

Contributing

Do you want to get your hands dirty and help make OpenZiti better? Contribute to the OpenZiti open-source project through bug reports, bug fixes, documentation, etc. Check out our guide on contributing to our projects here.

License

Apache 2.0

Download files

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

Source Distribution

openziti-1.7.1.tar.gz (39.1 kB view details)

Uploaded Source

File details

Details for the file openziti-1.7.1.tar.gz.

File metadata

  • Download URL: openziti-1.7.1.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for openziti-1.7.1.tar.gz
Algorithm Hash digest
SHA256 1c403a4391f41d91a84d5c7ae6d415d0c3403d0c18636d46786ce2fc910fd96f
MD5 4f557fc3eae804ec51123dbb7f0311b2
BLAKE2b-256 bf466f1c133453270e46db20966b501b83f8c5c5706aabce8500d5b0693d21c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for openziti-1.7.1.tar.gz:

Publisher: wheels.yml on openziti/ziti-sdk-py

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

Release history Release notifications | RSS feed

This release

1.7.1 This release

1 file

1.7.0

1 file

1.6.0

1 file

1.5.0

1 file

1.4.1

1 file

1.3.1

1 file

1.3.0

1 file

1.2.0

1 file

1.1.0

1 file

1.0.0

1 file

0.8.1

1 file

0.8.0

1 file

0.7.7

1 file

0.7.6

1 file

0.7.5

1 file

0.7.4

1 file

0.7.3

1 file

0.7.2

1 file

0.7.1

1 file

0.7.0

1 file

0.6.0

3 files

0.5.3

3 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page