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

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.4.1.tar.gz (218.7 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.4.1-cp311-cp311-macosx_11_0_arm64.whl (706.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

krb5-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl (777.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

krb5-0.4.1-cp310-cp310-macosx_11_0_arm64.whl (714.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

krb5-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl (782.8 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

krb5-0.4.1-cp39-cp39-macosx_11_0_arm64.whl (724.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

krb5-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl (797.0 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

krb5-0.4.1-cp38-cp38-macosx_11_0_arm64.whl (707.6 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

krb5-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl (777.4 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

krb5-0.4.1-cp37-cp37m-macosx_10_9_x86_64.whl (779.9 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.4.1.tar.gz
  • Upload date:
  • Size: 218.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for krb5-0.4.1.tar.gz
Algorithm Hash digest
SHA256 606059b9db52086f4e03e15b161d1d172ccc1172880e42fa5744f99a4407cf57
MD5 6b2da57335462830909307760116e41c
BLAKE2b-256 56f664874f52a47e652e37c8648665374e723500a62d82938ea2db842496d2ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d860cf81f45b1dce9b7ec9768725d68fe225e18cfe90d97dd06a6ebd405c7978
MD5 7ce1eb2c786c44a3d0649888607c7482
BLAKE2b-256 9463ab05bf9535f30bf702715534dec3feeaf28204081ff2ca3fdc2dffc5d31b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7c302fc7e3da7af69f10a74b65bc193815f61fb2f02017511e93309654b8d624
MD5 20c09f8b394fd10601575f7693fcb110
BLAKE2b-256 c7f72b824b8fe8d418e6ca52de7777ceff8d2f450e4db9364db6f95dd8b78621

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76064046be1c9de0c3c8aec076f55f9af5e7ad736feb31c257caadc3ce29f6c6
MD5 80de3d7faefddb7212c2e54cd06b1a97
BLAKE2b-256 7d2f85cfbbeba719575188e9f55c709f9bd54ec00c88f3c63123f1b57f1a979e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cc53328d38f08267986a70d6dddf8e71f15a573df58dcf2f475edafdd5f20d4c
MD5 1e37f9d0b4e228848bf0aabc36c10372
BLAKE2b-256 7338a8ce23b8e464106ee9d3ebdcc1ee96801ae58cbbcbfd654d88b9dfe5f97a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krb5-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 724.6 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for krb5-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 474ef323593b0cd0d5d35f2deaccc828f544843a1e88cf93ba3fa385c3332228
MD5 cd6a5dd6d2d065bb286bb04f4688f694
BLAKE2b-256 a00b8e074a0a7b2876ac86c556f0654380a1ccccb1aebe31153e5df3fe99f60a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krb5-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 797.0 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for krb5-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 82251d33ee1f393de64ec69bfe3ade32a7e8af6196aca42ae52574d8cc48be77
MD5 41154cc6dccebdb0d6cdbc333be3ccd4
BLAKE2b-256 c266b0f0ea0d4066ad0b853f79ccf1e78a9335ae82b606d84a1ce7ba57c4f036

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krb5-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 707.6 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for krb5-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90b21dfc2a9dc1b8ded6791cbdd80bfb277682ce372f9119e25e233581c334dd
MD5 9e99981d5e5f09ea344e83cd667f298c
BLAKE2b-256 2bf64c9cf7f6aa51d9b344d07d92ee8ddbeb4ed7a0ee0044b21c8202892517a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krb5-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 777.4 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for krb5-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1b4027d46dfdbbb3dc17ceae83f797609216f57bdf24b6b953d2cf4b7b0e1692
MD5 e46e864a5a45cf4f9cd3e129fe14e2e4
BLAKE2b-256 9f18e7500ef093ea856473e64a3824b38fa0b62b70b7c553e5b3bbf06560a7ce

See more details on using hashes here.

File details

Details for the file krb5-0.4.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.4.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 15fb7c19dd2edb0b9cfc9743499c4dc4a852d2aca13223280b6b7ffa70e8834b
MD5 ece3feb5df7a24114d424f0c9af82a88
BLAKE2b-256 6ed1591d4fbccc04da07ee3339ffe8af41a2f285a7e7479dc561d9dc8a013c0f

See more details on using hashes here.

Supported by

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