Kanidm client library
Project description
Kanidm
A Python module for interacting with Kanidm.
Currently in very very very early beta, please log an issue for feature requests and bugs.
Installation
python -m pip install kanidm
Documentation
Documentation can be generated by cloning the repository and running
make docs/pykanidm/build. The documentation will appear in ./pykanidm/site. You'll need make and the
uv package installed.
Testing
Set up your dev environment using uv - python -m pip install uv && uv sync.
Pytest it used for testing, if you don't have a live server to test against and config set up, use
uv run pytest -m 'not network'.
OpenAPI client generation
The OpenAPI spec is served by the running Kanidm server. To generate/update the OpenAPI-based client package:
uv run kanidm_openapi_codegen
You can also point it at a local spec file or override the URL:
uv run kanidm_openapi_codegen --spec-file /path/to/openapi.json
uv run kanidm_openapi_codegen --spec-url https://localhost:8443/docs/v1/openapi.json
Programmatic code generation lives in kanidm.openapi_codegen, which is behind the optional feature openapi_codegen:
python -m pip install "kanidm[openapi_codegen]"
Programmatic use is also supported:
from pathlib import Path
from kanidm.openapi_codegen import generate_openapi_client
generate_openapi_client(
spec_url="https://localhost:8443/docs/v1/openapi.json",
verify_tls=True,
ca_file=Path("/tmp/kanidm/ca.pem"),
# season to taste
output=Path("pykanidm/kanidm_openapi_client"),
)
The generated client is packaged as kanidm_openapi_client.
KanidmClient now initializes an OpenAPI client by default at startup as client.openapi_client:
from kanidm import KanidmClient
client = KanidmClient(uri="https://localhost:8443")
openapi_client = client.openapi_client
You can still build one explicitly from config helpers in kanidm.openapi if needed.
OpenAPI structure
kanidm_openapi_client/contains the generated OpenAPI client (API classes, models, and transport).kanidm/openapi.pyprovides helpers to build an OpenAPIApiClientfrom aKanidmClient/KanidmClientConfig.- The generated package is included in the build via
tool.pdm.build.includes.
OpenAPI spec tests
Networked OpenAPI tests are marked openapi and include both spec validation and generated-client GET calls. Run them
with:
IDM_ADMIN_PASS=... uv run pytest -m openapi
OpenAPI tests regenerate kanidm_openapi_client once per pytest session before running marked tests. This uses
kanidm.openapi_codegen and requires Docker to be available.
Optional environment overrides:
KANIDM_CA_PATH(default:/tmp/kanidm/ca.pemif present)KANIDM_OPENAPI_URL(default:https://localhost:8443)IDM_ADMIN_PASS(required for auth'd OpenAPI tests; matchesscripts/setup_dev_environment.sh)KANIDM_INSECURE(true/false, default:false) disables TLS verification for tests
Note: tests always verify TLS unless KANIDM_INSECURE=true. Provide a CA via KANIDM_CA_PATH (or use the default
/tmp/kanidm/ca.pem) so the server cert validates.
Changelog
| Version | Date | Notes |
|---|---|---|
| 0.0.1 | 2022-08-16 | Initial release |
| 0.0.2 | 2022-08-16 | Updated license, including test code in package |
| 0.0.3 | 2022-08-17 | Updated test suite to allow skipping of network tests |
| 1.2.0 | 2025-05-13 | Replaced poetry with uv for packaging |
| 1.3.0 | 2026-02-19 | Major rewrite to use openapi-generated codebase, based on 1.9.0 API |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kanidm-1.3.0.tar.gz.
File metadata
- Download URL: kanidm-1.3.0.tar.gz
- Upload date:
- Size: 149.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a55315bf6c9072427ccf75177d679a52b47dbb4a95ab0a28d97398e5553e631
|
|
| MD5 |
f27a9d77718805387ad168426522652c
|
|
| BLAKE2b-256 |
d34a61f5caeea8dd9fc515ae4dc1e0307472ac34f44035754ad236d8e2db9e6c
|
File details
Details for the file kanidm-1.3.0-py3-none-any.whl.
File metadata
- Download URL: kanidm-1.3.0-py3-none-any.whl
- Upload date:
- Size: 363.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e34f98c9e7275d82115c494de6ccd3b07bec89744e071d51fdaa2e11ac20b24b
|
|
| MD5 |
1ac8c3d863519b8dbea1afa70cf16ba7
|
|
| BLAKE2b-256 |
f5cd557a948b8cad7ec81f7bde8c09c7d9de2debfd3e05d30092cc6e965c9c50
|