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

Uploaded Source

Built Distributions

krb5-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (455.3 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl (501.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (455.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.1.2-cp39-cp39-macosx_10_9_x86_64.whl (501.7 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.1.2-cp38-cp38-macosx_11_0_arm64.whl (443.5 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.1.2-cp38-cp38-macosx_10_9_x86_64.whl (487.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

krb5-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl (489.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

krb5-0.1.2-cp36-cp36m-macosx_10_9_x86_64.whl (491.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.1.2.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.1.2.tar.gz
Algorithm Hash digest
SHA256 9d8cfafc3db34c8d7ebdb62640b5dbc5342b6892fcad528611da9c258a679cb0
MD5 3a28ffa2eb60e27523c1cdaba51f1e11
BLAKE2b-256 6bc2c26bd3d21f0970c866f42c2d628ec11399345201cbf3b4f7ae587baabb84

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 455.3 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.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3bbf3dbd8274c36b6eac343fd8902c96fb3fe5f8f6c6e523cac52449e62384c
MD5 a2f148f4f4a4984b1dca52268ba16730
BLAKE2b-256 bde3146d4da39748db2b573d0fe11619680556fc2f1ea14052f8e30dcccc05dc

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 501.7 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.1.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bdecff940b36919945a4f27675c66dc99f40dfa464d23cec9bf0746e96982f6c
MD5 f47e6dcc477348518f64d2d36bb82df4
BLAKE2b-256 d8478c30bcf530db0ba6234349433198d4d7ef30bc5a01b656631d8231e327a5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 455.2 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.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f664a52231054ff36b02818696488750b3df6a09c6ff83bb7355ead92641190f
MD5 b0ce249797c0cbcf5c8ea9dd5c7922bf
BLAKE2b-256 7dbae499c2bef3f211dc107b8c3d627fb066217448e06d8a8849ba01eaea92ba

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 501.7 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.1.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c87affb91dd460a6c111aa60016d220fb915e9808c54c2a7c7bc2ee3177278c5
MD5 2cc1bef3f5487e724ff8291d6bdfbdf7
BLAKE2b-256 04642a29eaa2b83302bdb105a481d7e3a3aca7c89b0a03ce67be11286897ad27

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 443.5 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.1.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27312099d554320cf26f974fc0b288eec4e667af929538f608c656e4f0687a7a
MD5 8f7cacc6aa4234438376440e09aebe7f
BLAKE2b-256 f2b2a732b101f4d4e947eca6f8bf2a5665820f0f9bad94a88ce6cb61711149f2

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 487.4 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.1.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d4912a5b3b3e31d99f4cf7c95849b2175247f1a614aa6078e9c8db9cf637ac93
MD5 6246d6604b9891c2c6cac4044452fc68
BLAKE2b-256 c91fb53d4e4918287a0414ebb1a48f6901c5a672d443929bf2fc25dbe79159e3

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 489.5 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.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8afd750bed8662dbd39e4c10a0219148d3d14c5886137875165b26dbe4abd8f2
MD5 f8ec156d9844c91ce85f12f6a4556fcc
BLAKE2b-256 5dff063d2d71abea7b0aee100f39580854c6642a85c2fe481d01b912b835f159

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: krb5-0.1.2-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 491.2 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.1.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 446c3c03190af8b477359b29fbbdefd483001dad11116fca9b774464f4540126
MD5 b9912231c88466437b5dc7454a3c9ce1
BLAKE2b-256 deeac5fe3ca89bcb8f406b75dc4ae3b93432a62d4efa5eb1a53a88d808162538

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