Skip to main content

Kerberos API bindings for Python

Project description

Python Kerberos 5 Library

Test workflow PyPI version License

This library provides Python functions that wraps the Kerberos 5 C API. Due to the complex nature of this API it is highly recommended to use something like python-gssapi which exposes the Kerberos authentication details through GSSAPI.

Requirements

  • An implementation of the Kerberos 5 API - including the header files
  • A C compiler, such as GCC
  • Python 3.6+

Note: macOS includes their own implementation of Heimdal and a compiler isn't needed on that platform if installing from the wheel.

Installation

Simply run:

pip install krb5

To install from source run the following:

git clone https://github.com/jborean93/pykrb5.git
python -m pip install build
python -m build
pip install dist/krb5-*.whl

Compiling the code should automatically pick up the proper paths for the KRB5 headers and locations. If further customisation is needed, the following environment variables can be set when building the wheel:

  • KRB5_KRB5CONFIG
    • The path to krb5-config to use for detecting the Kerberos library to link to
    • The compiler and linker args are derived from what this function outputs
    • Defaults to whatever krb5-config is on the PATH
    • FreeBSD will default to /usr/local/bin/krb5-config instead of /usr/bin/krb5-config
  • KRB5_MAIN_LIB
    • The path to the libkrb5 shared library used to check if any of the optional functions are available
  • KRB5_COMPILER_ARGS
    • Compiler flags to use when compiling the extensions
    • Defaults to the output of krb5-config --cflags krb5 if not set
  • KRB5_LINKER_ARGS
    • Linker flags to use when compiling the extensions
    • Defaults to the output of krb5-config --libs krb5 if not set
  • KRB5_SKIP_MODULE_CHECK
    • Skips the checks used to detect if optional functions are available - will treat them all as available
    • This is only really useful when building the sdist as no implementation provides all these functions
  • KRB5_CYTHON_TRACING
    • Used to generate the Cython extensions with line tracing for coverage collection
  • KRB5_MACOS_HEIMDAL_DIR
    • Used when compiling on macOS to point to the Heimdal install directory
    • Used to find the Heimdal header files as macOS does not include, or provide a way to obtain, these header files for their Heimdal framework
    • Defaults to {git_root}/build_helpers/heimdal

Development

To run the tests or make changes to this repo run the following:

git clone https://github.com/jborean93/pykrb5.git
pip install -r requirements-dev.txt
pre-commit install

python -m pip install -e .

# Can compile the krb5 extensions on an adhoc basis
# python setup.py build_ext --inplace

From there an editor like VSCode can be used to make changes and run the test suite. To recompile the Cython files after a change run the build_ext --inplace command.

Structure

This library is merely a wrapper around the Kerberos 5 APIs. The functions under the krb5 namespace match the KRB5 API specification but with the krb5_ prefix remove. For example the krb5_init_context function is called through krb5.init_context(). Errors are raised as a Krb5Error which contains the message as formatted by the KRB5 implementation and the error code for that error. Some of the structures returned by these functions are represented by a Python class and are freed once they are deallocated once all references to that object is removed. Some classes expose an addr property that returns the raw pointer address of the structure it is wrapping. This is so the structure can be used in other libraries like python-gssapi but great care must be taken that nothing else frees the structure as that could cause a segmentation fault.

Not all the functions exposed in this library are available on every KRB5 API implementation. To check if a function is available run the following:

import krb5

if not hasattr(krb5, "kt_dup"):
    raise Exception("Current implementation does not support krb5_kt_dup")

There may also be some difference in behaviour, error codes, error messages, between te different implementations. It is up to the caller to paper over these differences when required.

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

krb5-0.7.0.tar.gz (235.7 kB view details)

Uploaded Source

Built Distributions

krb5-0.7.0-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

krb5-0.7.0-cp313-cp313-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13 macOS 10.13+ x86-64

krb5-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

krb5-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

krb5-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

krb5-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

krb5-0.7.0-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.7.0-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.7.0-cp38-cp38-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file krb5-0.7.0.tar.gz.

File metadata

  • Download URL: krb5-0.7.0.tar.gz
  • Upload date:
  • Size: 235.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for krb5-0.7.0.tar.gz
Algorithm Hash digest
SHA256 6a308f2e17d151c395b24e6aec7bdff6a56fe3627a32042fc86d412398a92ddd
MD5 2c707f2fd06826ab6680a92b889f8de6
BLAKE2b-256 429aa1eacfede9cb66fce3edb62ff62e8f296a64dabe1408a63e6666ceb4ced9

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 691e2eafd0b16cb1b209b2bd36888526ea7df24ce69ba39e72ccad281ffdadb2
MD5 4cc5ab6b4d3ad1fe9105c78a5321626c
BLAKE2b-256 7b34961960e224a51301b26a13171cea44b0fa30604fd02f225846d6974ed02e

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 87a6d11bb182a289dd86086c19cba3f03a8108175e8e23292d3d2786ff3ecaeb
MD5 f9363f2315c5bcf880b7dae386ffc867
BLAKE2b-256 d1c29aeeca5738f99735f9755c2ccd378573bcea02a72675a089a30ab26117be

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a33896483f6d415c4289e5cc108b0450a919bae0546a997f3352d982bd4e7c99
MD5 bdb5125c6ca628889d71214fa8ae703c
BLAKE2b-256 315e911ff98bcf57dd47abe17adfa22279ed17d23ea3baabb72b9f3bc29cf17f

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fa4ea45629e585787c0bcc455c7fbed7e09176031a7f9e7c87b9deaad401da36
MD5 86a9368e67f6bbe479b38a58a631c20f
BLAKE2b-256 2f09779082321824a9ebe0ee2d51f19a84c8f12425441572bda90d86674958c9

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66b286d9b4af42b4f5d2d561354cd44d891bee275768f1a2ac795ad4e8042dce
MD5 b7c3ed937d22fe621aae35b2cbda7df9
BLAKE2b-256 abd45e7ccdeb2b1fa872daf03fbbd00476957bca3f388dfdf770122c2cbbb835

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 717e5b8b4d78268eefdba72a39cb0f93e5821a23e626ada3a45a583a2454d084
MD5 3f8f8c733dfdc71e8444317ff5de95a4
BLAKE2b-256 137070c871e2254a1337336e2f04004c8fd83694fee2b3de5ccefe5470402a9e

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a32a35e425ce967f5577f9247a4e0a7d7e9a7e4527a778f7e0719aeb99e295f
MD5 8c0455625ba54a78bb0f66451beffe8d
BLAKE2b-256 a31b28cdd6ed4db73c9670b8d199fc73310d347a065419aa078744fce7cb797a

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 69dc98084de5d693a97725f746d5af46299590bb9658c9fc32e4769a4a0f3079
MD5 455675514549aa7a8eda35f67ed2ec54
BLAKE2b-256 cd60e8d6c83af41cdd3d75bf05da3e2cc949417d5de8d8f4b4a7eaf54776ffda

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2cef1a7f78d331cc07b69cb8dc4cfb4a80f7b11dc2949f4e81f8cf86fd1836a
MD5 37e154fee1f634bbcb9272e8a4fce9e3
BLAKE2b-256 123802abf5401dcd782dab38fab52cb2c75ad4726a5b319a9ed42499dfef70a5

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72d551ce659502f3a7c46c65cdd75af682c077d3d1a081d4d1bb478e14a55ffd
MD5 ff9989c8413b3f9931f767f783fca911
BLAKE2b-256 1e7269045d475f394b64ca29af802f5e7361d81bab1ba23efe58294870849042

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aead8037a4ef3f8a12db09fec32ff7f561399a35970c40bf62d748b834ac0eb5
MD5 06b84294b8c311bfeb0b836600e707e4
BLAKE2b-256 4e13fbdb1a9f5f7331fe44d66fdac11a49f937d088a51282974cb3ece7cf9cff

See more details on using hashes here.

File details

Details for the file krb5-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dd954a76973ddc295756a5741e7fcfda70cfd31d965d45ed47422bffe5792b6f
MD5 183f1ab580a8d607c52c8bcef626cb96
BLAKE2b-256 9bbfd99f47c907463caf472be5c02f30bcd44803d04bed17023b6ccc0d1e04ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page