Skip to main content

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.9+

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.

Python Free-Threading (PEP 779)

This library supports Python Free-Threading and will build free-threading-compatible extension files if installed under a free-threading interpreter. Python 3.14t is tested in CI and a wheel for macOS will be created for 3.14t. Python 3.13t is not officially tested or supported but may or may not work. There is limited testing for free-threading in this library and it does not aim to be thread safe out of the box. If you encounter any issues or problems with this scenario please raise an issue and we can look at possible options to fix this.

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.10.0.tar.gz (237.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.15tmacOS 11.0+ ARM64

krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.15tmacOS 10.15+ x86-64

krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmacOS 10.15+ x86-64

krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl (985.8 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl (953.5 kB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for krb5-0.10.0.tar.gz
Algorithm Hash digest
SHA256 8f4711a0ab11ee43fda567371ef6d9487afdbd4f156ca093e8fb306f4cc685ae
MD5 a655650ffac54bb29673582551d2afef
BLAKE2b-256 84c991bc5f7bee581dbe134d9a0335ebf2eeece855eed058331905a589b5f630

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0.tar.gz:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ad9a9de0ec606d35c972abfb642659d0754910f313fd7d3e11bafdbf66481b8
MD5 d1ae07ee6eb53d69587cbe58d05b9d2b
BLAKE2b-256 630a0d14d1d5e26307369c42ad6f4c00d061c61bfc5d270356f7be01462dd5e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 08eba9a21daf3e4b06f6262b5798dd67cfdb4ccba155357fb4c23691d7b290d9
MD5 1344bb67d0ee720da74e85a3ab70a996
BLAKE2b-256 72d69c3dd3ba7fd7e4fde81676f892a7f6c7a3479069afb22005b965ddfe44de

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f09545cfbf7a21f77738efe56428faf96fb9d14f2b7e462dadfe81e71a4ac1bc
MD5 4b3753db77b9b346e85e750c172e4173
BLAKE2b-256 7a6d0908176044bcc35518d9780add79d939db086d79a6076b01a2ad98e5ad06

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d6bdedb24a94d2b82084cc196cb6dda1ee67c0ff0882bafdac56d2e7ea7dc454
MD5 fbb8819b041e5d47c9b7882cb4695df4
BLAKE2b-256 135a46a1a1f48d46731e0ff6fbbc8c19c6dbc0b663f6fb235bbf0f85e6a5b185

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 985.8 kB
  • Tags: CPython 3.11+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 644f4c6080b7940a8006e3f48c762ac1845d2cbf8894e5c428f2ebc11fb7f0c3
MD5 897b935f82b19854f0f5ed94727b5f7e
BLAKE2b-256 b9c4c5cee95a4a251c5166ac4300081fc9d7620be8f1a4697b35133b35b533d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

Details for the file krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 07c2de3a4f99ddf53f022e66e66583cd5ec938a8c1690881ee95a3225cd8c7ca
MD5 1c8bd31a9a40292df312fd52c3c2e176
BLAKE2b-256 54dab9f5f738f04bc70448b5d4f5febfbef4fbc07cae51522015868970ff7463

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

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

File metadata

File hashes

Hashes for krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1db7c0a50d3f8f74ef965c6c94426e5a4acc4e6cfa186086ae0606d120e75bd0
MD5 29fb407dc59753e3ea810c36ab291dee
BLAKE2b-256 2a7e7f7c9e03c2058da7ae501d5bff7654fd07ab42f209271784eed9c35b52e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

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

File metadata

File hashes

Hashes for krb5-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bbb82e345b5977df328080c68e3725840fe1b5a65b814c352913f44c62323b22
MD5 1e87e97c986b66b0a9e05514ac002fab
BLAKE2b-256 35e58a1f26382fa0ec4598d40442a310bd0bc957c406ba527abfe34e2a0bd317

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

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

File metadata

  • Download URL: krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db37de673b60aefb9115a196f9ccf6d97d421ec60ac7d8d46db53d5fb7114cef
MD5 653a343ff2c51fc5182f8f4e77946b4c
BLAKE2b-256 dbef7e1c75089018c91e773176116b6a67d97755e4da883460eb23988e84eaa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

File details

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

File metadata

File hashes

Hashes for krb5-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e1bcee0cf56a12b1d9c498cd5972fadd73733aedf601529fc1d54311b4658043
MD5 dfff9b14d206df0857314ddac88810ce
BLAKE2b-256 aee9654d7d23c35d1a6c72fc1da7a4e7d5982d3d54bc457c8e7c81fed96dcfa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

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

0.10.0 This release

11 files

0.9.0

9 files

0.8.0

13 files

0.7.1

13 files

0.7.0

13 files

0.6.0

12 files

0.5.1

12 files

0.5.0

10 files

0.4.1

10 files

0.4.0

8 files

0.3.0

9 files

0.2.0

9 files

0.1.2

9 files

0.1.1

7 files

0.1.0

6 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