Skip to main content

unlok

PyPI version PyPI pyversions

The python client for lok, the authentication and identity server of an Arkitekt deployment: users and groups, apps, releases and their clients, the services a deployment composes, and the redeem tokens deployed apps enrol with.

Installation

pip install unlok

With arkitekt, pip install "arkitekt[rekuest,unlok]" brings it in.

Usage

Every lok operation is a method of the Unlok client, in a blocking and an a-prefixed async flavour (unlok.me(), await unlok.ame()).

Unlike the other service clients, unlok requires nothing from the deployment: it talks to the app's own lok server, the one the app authenticated against.

In an arkitekt app

Add the service to your app and ask for unlok: Unlok; the client is injected by annotation. Services travel between actions by id (@lok/service):

from arkitekt import App, run
from unlok import Unlok, unlok_service

app = App("whoami", "0.1.0", services=[unlok_service])


@app.action
def whoami(unlok: Unlok) -> str:
    """Who Am I

    The user this app is acting for.
    """
    return unlok.me().username


if __name__ == "__main__":
    run(app)

From a script

from arkitekt import easy
from unlok import unlok_service

with easy("my-script", unlok_service) as unlok:
    for service in unlok.list_services():
        print(service.identifier, service.name)

Testing

Unit tests need nothing but the package:

uv run pytest -k "not integration"

The integration tests start a real lok (plus postgres, redis and minio) with docker compose through dokker, enrol into it the way a deployed app does — by redeeming the token provisioned in tests/integration/configs/lok.yaml through the fakts redeem grant — and then exercise the client against it, including the pinned redeem-token flow a deployer drives:

uv run pytest -m integration

The stack runs the published jhnnsrs/lok:${LOK_SERVICE_TAG:-latest} image, so the schema under test is whatever was last pushed to :latest. CI defaults to the same tag; set the repository variable LOK_SERVICE_TAG (or export it locally) to test against another published tag, such as next. To test against a local server checkout instead, drop a gitignored tests/integration/docker-compose.local.yml next to the compose file that builds the lok service from that checkout; the fixtures pick it up automatically.

Metadata

Release files for unlok 4.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unlok 4.1.0
File Size Uploaded
unlok-4.1.0.tar.gz 31.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unlok 4.1.0
File Interpreter ABI Platform
unlok-4.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.1 kB

Release files / unlok-4.1.0.tar.gz

Download URL unlok-4.1.0.tar.gz
Size 31.0 kB
Tags Source
SHA-256 checksum
How to use checksums
149ae323294fa602ffaf45165bfdc305025eb57c3c3aa84c3461e038904680f1
BLAKE2b-256 checksum
How to use checksums
e76760351386ac9ec1cfd90337c26b73b8d16e6f353e722e0a1f4a6fdc0d1f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / unlok-4.1.0-py3-none-any.whl

Download URL unlok-4.1.0-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50d91584c806c9eaafab5040299c5e7eb4eda817e6b04d82d4aa33f1c8cc7629
BLAKE2b-256 checksum
How to use checksums
7074e6befe07aa41105b0602d0c461dff0fdf58fb9d39c66f401a62dce7e8b07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

5.0.0

2 release files

4.2.1

2 release files

4.2.0

2 release files

This release

4.1.0 This release

2 release files

4.0.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0.0

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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