Skip to content

Latest commit

 

History

History
95 lines (60 loc) · 3.76 KB

README.md

File metadata and controls

95 lines (60 loc) · 3.76 KB

Python SDK for OpenZiti Examples

Setup

You will need an OpenZiti network to use the examples. If you don't already have one running, you can follow our express install guides to set up the network that fits your needs. You could also use ZEDS (Ziti Edge Developer Sandbox) or, you can try cloud Ziti 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

Install Python Requirements

First, you'll need the dependent libraries used in the examples.

cd ./sample
pip install -r requirements

Get and Enroll an Identity

You need an identity to be used by the example application. If using ZEDS you can grab one from there, otherwise you can find all the information you need for creating and enrolling an identity in the doc here.

Alternatively, if you have an identity enrollment token (JWT file), you can perform the enrollment with the Python SDK.

python -m openziti enroll --jwt=</path/to/enrollment-token-file.jwt> --identity=</path/to/id.json>

Environment

The ZITI_IDENTITIES environment variable can be used to store the paths to any identity files you have. If you have more than one identity file, you can use the ; operator as a delimiter to provide additional identities.

export ZITI_IDENTITIES=</path/to/id.json>

There is an optional environment variable ZITI_LOG which, by default is set to 1. This value can be adjusted to output more or less log information. A ZITI_LOG level of 6 will output TRACE level logs.

Network

Your network overlay needs to have a Service, and the proper Service Configurations, the documentation for which is linked.

If you happen to be using ZEDS you are in luck, these examples will use default services that are already implemented in the developer sandbox.

Examples

Note All but the Flazk example scripts use predefined services in ZEDS by default.

An example showing the simplicity in integrating zero trust into a web server or API using Flask. This example also shows how to use the decorator to apply the monkeypatch. flask-of-ziti/helloFlazk.py

An example showing how to open a socket to listen on the network overlay for a particular service and send all bytes received back to the sender.

An example showing how to monkeypatch http.server to listen for HTTP requests on the network overlay. When a request is captured, a response with a simple JSON document is sent to clients.

An example showing the use of Ziti monkey patching a standard socket, via the requests module, to intercept network connections using Ziti overlay.

An example showing the use of a raw Ziti socket.

An example showing how to monkeypatch urllib3 to fetch a Ziti service using HTTP.

Upload some log files to a private S3 bucket via the Ziti with the boto3 SDK.