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.2.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

krb5-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (458.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (505.4 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (458.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (505.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.2.0-cp38-cp38-macosx_11_0_arm64.whl (446.4 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (491.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

krb5-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (493.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

krb5-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl (494.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.2.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0.tar.gz
Algorithm Hash digest
SHA256 67df5e0f974ea97d4bfb4ef8f8cc4a2172894b6cdba01f3315f33abcfb2cc41b
MD5 8c0892321bd96e5328f4005e8b454372
BLAKE2b-256 edb0dedaff49b8137f558a53ce1ea49b04091e0a6a99b779fbddc56556750cfb

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 458.1 kB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61a9c8aa2d71c12a26fd4110967e6a31002627ef20fc8199406281f8c833f196
MD5 94c8eb97a87f71689b72e9475ec37d80
BLAKE2b-256 536e4737e833ac29e7837016c18422e412a196504f1c53b306471899ff8a4384

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 505.4 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 21e40bd3f05db9d66aaa0e23556889f47cdb9ee5f32a48bd4103ba5c1b9f5db2
MD5 7877ed2583d31c43383b55e9272ba36a
BLAKE2b-256 6cb593ef412d7c4e8d1c2f84639e671d2cb830446f5a8ae194be4db60e709c19

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 458.0 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7873197ac130607000c70d5b6c6b2232c69c76d6b88142d7417dfb5bde2269d1
MD5 87733037472f4054d3f7e9b4e400aa82
BLAKE2b-256 2cbb781eb155e2e654a2e9262cea16fe8bed53eaf9cb3b5eb00ca402e3f8ff30

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 505.3 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a4e97e118d57ebae10cfaff11ece2b9f453c9c0406db9e18b9966c126014aad5
MD5 c30ea0ab83382891f881e3bdcfe2247e
BLAKE2b-256 f36e593dc393325ebd92476bb8464c9bf349331bffae53e44cb308258d5e4d44

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 446.4 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c99f9d78fa23b6ece55697be201fdffeb932d14a8302c1d4af0bd48553675d2e
MD5 f306b6e39e8a3dabcc7bf40afe074f0d
BLAKE2b-256 454e17323bc33da6d2d875a0bc06c7dc5f5c48beb8d5b51c940df7a25e618dec

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 491.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 86d0ae09c4239cbe14a7da5ac46020eee3a9f9d9f54f11fc126f2e9a19bb3584
MD5 e68eaec9ca9fbac5eb5d560fe2e0dc37
BLAKE2b-256 acdc459df9dfb1ad1b1d04a4bd98c3d2761c165d3ff3fa89c2e24502885c28e5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 493.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0930bcc03dff6f87342f15214dfd971e3af3e1c7013e2b26858b9064cd869491
MD5 d77642604f929fb7d91924e94807f05d
BLAKE2b-256 a08861a026627f95ed6106bf1a37a1c9765585b63c58007fc28d5e6bc638cd35

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 494.8 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for krb5-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6aadccabfd7bd2bfcd02afba67586fb34f09dc761adb706e313d2a1c4f17e7c0
MD5 1bfa8d5033769fae5582a51d57fcb91e
BLAKE2b-256 ec3dd8e0695c65bbdb98b68cc19dc4e4fe60bfaed0c42805a18d467e439f81db

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