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.

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.8.0.tar.gz (235.5 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.8.0-cp314-cp314-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

krb5-0.8.0-cp314-cp314-macosx_10_13_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14macOS 10.13+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

krb5-0.8.0-cp313-cp313-macosx_10_13_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

krb5-0.8.0-cp312-cp312-macosx_10_13_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

krb5-0.8.0-cp311-cp311-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

krb5-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

krb5-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.8.0.tar.gz
  • Upload date:
  • Size: 235.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.8.0.tar.gz
Algorithm Hash digest
SHA256 daaf580cf563a2435cc889d4a0692e02c5788e1eb91f0246d56114cf4f08ba1c
MD5 474b79c2bfb50fcee95f0df84db5386b
BLAKE2b-256 380fc19e3a6606f2b13e0fd72e8119b3e51f8e55a07c68dcda75fe6cec438c0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.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.8.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01da7371927570b6b855b445cdcdc062e082f68ddfbb268d8eba9ec939dd0bc6
MD5 70df4189788b45105d1fb7f61961e0e8
BLAKE2b-256 821ce3dbedbab065ad231d8ac9377dc7b649384c0898a6c693cf4071fdc4aa3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp314-cp314-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.8.0-cp314-cp314-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp314-cp314-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 217edee66b2afb99174b5093257c5fb056e6a3661087fb5bf086cea57c8aac39
MD5 9a8c54619a899302c9b0f4a92d502d34
BLAKE2b-256 8324d2fcb38e2597ad1ce96aa6b25415281fde505807d1c4062697d1dbaac16c

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp314-cp314-macosx_10_13_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.8.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bde91ff45a467f642ad5945a5af869399ffe1f69b86e278be23e1528742576c
MD5 fdcb6076dedbedb4f2efe796710d4135
BLAKE2b-256 3c76dcdd72a7936948121bf6a990e4b18c7623cc0b183acdfb3c13110c292460

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp313-cp313-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.8.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 da523a5f5fb0044daf035735901b84211f16acb54b2c2529649a48eb50431448
MD5 7b65eb14f974bbb88c0554c8b2537550
BLAKE2b-256 eaf628240e5360afb474f83c892a99b5ad6788f00408e4ae1b90bc3aec1dab62

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp313-cp313-macosx_10_13_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.8.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00b22684deb5816d08f56b8f3e8c0c9ee5624e82bc41c7189e55737da7b15c85
MD5 8218b7855c0885022c58f58d364f2f90
BLAKE2b-256 77edd142c30e50642d8f5821d454f2f1fc2c5e68d01ad26fd26bb4ccc581fd12

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp312-cp312-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.8.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c4c939e0d06f3db1e8c7a8ee51d351ce2a2b6f8a114837077ede046ef26b66b0
MD5 ccaec52406b930e09e36792b29c458c0
BLAKE2b-256 b1323ba5a44fe4aa88f4cd87657d21e73699f31a7b6a7a4063de16ad0ce34295

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp312-cp312-macosx_10_13_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.8.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53baadc64784f470729ef82e87f0c4d50c7c30f59b082966d31c76bf3c01b3d4
MD5 27de68180f4c4c917fe69c27c28927dd
BLAKE2b-256 a439b097b23e8c8532041c7aa7195f209430ad2296d4dd763c43821710c62ec8

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp311-cp311-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.8.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 244ea9320f7f263f6f17ab525b17518439a383286f8b1773cb10e25f732e7bb5
MD5 a8f518efc6801ae25d0b5c16c2f42496
BLAKE2b-256 b118e895e75c9e15882f8aa0c94351aa2c76b064a417bc485f91a8946c247ee2

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.0-cp311-cp311-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.8.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1adc4052d48488c69aa2cfd141cdba8ec8c6cd71f3191c910959fc6de225673f
MD5 1c2b4f42a90d8348f2b787a24015ef40
BLAKE2b-256 ff1e2d368412e3f4b0842b68f6177f16d6ed9a1f0db3077809a758a8c1431afd

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.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.8.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 937761d1e5b59132f9dd2f599e78bd279d4134d621391944432beda50a716bec
MD5 403481a399ffec5a3fce3cc4a0b24405
BLAKE2b-256 9133a94e9d4ab4958467d30fb74ab68c74912edee758b453a8fd4eeb1ca1feef

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.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.8.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: krb5-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18fd7225e29a6e310dcf83f9099332574eca5752df00570c3ed09b0e7799b919
MD5 52763772ff237f8d66dc7fbe89f0608a
BLAKE2b-256 b61f7308a2869e20abe3f34763b5eb0df31c9e61ba6a3739720fd088b049076a

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.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.8.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: krb5-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e372a77e4eed6a7c17ce0fff9f52f160c036c89b76d5b8cf2754af1464d4eb34
MD5 d5e9ebe640f4761490479deb8b7b94ba
BLAKE2b-256 35f1a955b12524083f5742781d1e09a31f343e514e014e9eec88bf2a96c4f5ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.8.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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page