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
pip install Cython
python setup.py bdist_wheel
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 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.3.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distributions

krb5-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (715.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl (788.3 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.3.0-cp39-cp39-macosx_11_0_arm64.whl (715.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl (787.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.3.0-cp38-cp38-macosx_11_0_arm64.whl (697.7 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl (766.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

krb5-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl (767.9 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

krb5-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl (768.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.3.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1d97da68aa8e563bedbbd5ac5fd02d3d84023b3526fd4df20dcbf7a89ee65d58
MD5 e8c5df291780e2abf9164e4724aa1ba4
BLAKE2b-256 d44ea18208fb107ada38738627b116a5fe55af96934957006ae26642584d69b2

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 715.8 kB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b99bf262c6eee88fb5c0476705e46c310230c2e1c9b5be365a3fbdae7d88899a
MD5 1587097e87433823d3cf18eef0aeef10
BLAKE2b-256 c1c6eb677e8f8848f916346539cd0b67d44ece331000ece3efdbc09fc4420020

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 788.3 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c08f543f5f4ae3ad2e2b8d70b21d1a4f06a82495583feb283b9bc426cd9d786
MD5 6f883db645cb76e0f2b6b15bbed750a8
BLAKE2b-256 0b5bc5f4169199aacc971ee28e5740076dbe517be4e653047d3eb74f9f4fad50

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 715.2 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b21d53b8cb23cd99146d89e11cb863d935c451b2e1345501819f1d80db3cabe2
MD5 044a5d460e49174773571dca97afc08b
BLAKE2b-256 32a3b9abdd37d289e331af6b03c4a59f9dd349ad4cf865ebcc69d2d13a286288

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 787.6 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 246171f4176cda9fab9b62c12f6291ff609aa9e2448a78d999dcfb32e6ba6f76
MD5 e2ae0e5d7cbc54414a7f79357c291a6f
BLAKE2b-256 1c613911cda8c23732c08bfb12de7d7b05efe572dfd1e623e56fd76499e2ef22

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 697.7 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d049fb3eb4ec11c9e81d8a1591a32b21b178b65bd03046933f7de1ddc981dc2a
MD5 01112b3c47db1b82b603f883a516f624
BLAKE2b-256 c0b84b42b58133d6d644d883ad467fc21816f38d094a38f1cd2d205da7791102

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 766.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 86bebf4ef64e57533ef6901907fabddff126aeae283d75464f06da86aab86e6a
MD5 cf35e7fa955f8b56da0e4438b00f1fd2
BLAKE2b-256 6523473ed3d4bae55d76638efa6fb3a41170ecfd1f6769e61b7d43bef3aae326

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 767.9 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5db3964b13fb8ec2a40fdf50927d6ec05a7f77c2146e78c46712f0a0c8fce468
MD5 c0161dae645a70ab53eb794cbf7b1bab
BLAKE2b-256 d155b412c83b025600381b2a5872c83fd9c630aadd7b4125a3eb2c15c6922b98

See more details on using hashes here.

Provenance

File details

Details for the file krb5-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: krb5-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 768.9 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for krb5-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dcf10648273e5722df67645d1979cb4084c31d03d63e6445b54d308e01d86b6d
MD5 9d5d6cd38fbf82cfdc4e5edf4de7e97a
BLAKE2b-256 706c8f3d2cef181f89c31104919fc04bb03616faf069841a573b677d2b47ff41

See more details on using hashes here.

Provenance

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