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.

Metadata

Release files for krb5 0.10.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 krb5 0.10.0
File Size Uploaded
krb5-0.10.0.tar.gz 237.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for krb5 0.10.0
File
krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64 Details
krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl CPython 3.15 CPython 3.15 free-threading macOS 10.15+ x86-64 Details
krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details
krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.15+ x86-64 Details
krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl CPython 3.11 abi3 macOS 10.9+ x86-64 Details
krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
krb5-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
krb5-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details

Total release size: 11.1 MB

Release files / krb5-0.10.0.tar.gz

Download URL krb5-0.10.0.tar.gz
Size 237.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8f4711a0ab11ee43fda567371ef6d9487afdbd4f156ca093e8fb306f4cc685ae
BLAKE2b-256 checksum
How to use checksums
84c991bc5f7bee581dbe134d9a0335ebf2eeece855eed058331905a589b5f630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl

Download URL krb5-0.10.0-cp315-cp315t-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4ad9a9de0ec606d35c972abfb642659d0754910f313fd7d3e11bafdbf66481b8
BLAKE2b-256 checksum
How to use checksums
630a0d14d1d5e26307369c42ad6f4c00d061c61bfc5d270356f7be01462dd5e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl

Download URL krb5-0.10.0-cp315-cp315t-macosx_10_15_x86_64.whl
Size 1.1 MB
Tags CPython 3.15 CPython 3.15 free-threading macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
08eba9a21daf3e4b06f6262b5798dd67cfdb4ccba155357fb4c23691d7b290d9
BLAKE2b-256 checksum
How to use checksums
72d69c3dd3ba7fd7e4fde81676f892a7f6c7a3479069afb22005b965ddfe44de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL krb5-0.10.0-cp314-cp314t-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f09545cfbf7a21f77738efe56428faf96fb9d14f2b7e462dadfe81e71a4ac1bc
BLAKE2b-256 checksum
How to use checksums
7a6d0908176044bcc35518d9780add79d939db086d79a6076b01a2ad98e5ad06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl

Download URL krb5-0.10.0-cp314-cp314t-macosx_10_15_x86_64.whl
Size 1.1 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
d6bdedb24a94d2b82084cc196cb6dda1ee67c0ff0882bafdac56d2e7ea7dc454
BLAKE2b-256 checksum
How to use checksums
135a46a1a1f48d46731e0ff6fbbc8c19c6dbc0b663f6fb235bbf0f85e6a5b185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL krb5-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
Size 985.8 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
644f4c6080b7940a8006e3f48c762ac1845d2cbf8894e5c428f2ebc11fb7f0c3
BLAKE2b-256 checksum
How to use checksums
b9c4c5cee95a4a251c5166ac4300081fc9d7620be8f1a4697b35133b35b533d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl

Download URL krb5-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl
Size 953.5 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
07c2de3a4f99ddf53f022e66e66583cd5ec938a8c1690881ee95a3225cd8c7ca
BLAKE2b-256 checksum
How to use checksums
54dab9f5f738f04bc70448b5d4f5febfbef4fbc07cae51522015868970ff7463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL krb5-0.10.0-cp310-cp310-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1db7c0a50d3f8f74ef965c6c94426e5a4acc4e6cfa186086ae0606d120e75bd0
BLAKE2b-256 checksum
How to use checksums
2a7e7f7c9e03c2058da7ae501d5bff7654fd07ab42f209271784eed9c35b52e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL krb5-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
bbb82e345b5977df328080c68e3725840fe1b5a65b814c352913f44c62323b22
BLAKE2b-256 checksum
How to use checksums
35e58a1f26382fa0ec4598d40442a310bd0bc957c406ba527abfe34e2a0bd317
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL krb5-0.10.0-cp39-cp39-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
db37de673b60aefb9115a196f9ccf6d97d421ec60ac7d8d46db53d5fb7114cef
BLAKE2b-256 checksum
How to use checksums
dbef7e1c75089018c91e773176116b6a67d97755e4da883460eb23988e84eaa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / krb5-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL krb5-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e1bcee0cf56a12b1d9c498cd5972fadd73733aedf601529fc1d54311b4658043
BLAKE2b-256 checksum
How to use checksums
aee9654d7d23c35d1a6c72fc1da7a4e7d5982d3d54bc457c8e7c81fed96dcfa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.10.0 This release

11 release files

0.9.0

9 release files

0.6.0

12 release files

0.5.1

12 release files

0.5.0

10 release files

0.4.1

10 release files

0.4.0

8 release files

0.3.0

9 release files

0.2.0

9 release files

0.1.2

9 release files

0.1.1

7 release files

0.1.0

6 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