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

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.6.0.tar.gz (230.4 kB view details)

Uploaded Source

Built Distributions

krb5-0.6.0-cp312-cp312-macosx_11_0_arm64.whl (941.2 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

krb5-0.6.0-cp312-cp312-macosx_10_9_x86_64.whl (998.2 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

krb5-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (930.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

krb5-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl (985.9 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

krb5-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (931.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl (986.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.6.0-cp39-cp39-macosx_11_0_arm64.whl (936.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.6.0-cp39-cp39-macosx_10_9_x86_64.whl (991.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.6.0-cp38-cp38-macosx_11_0_arm64.whl (933.2 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.6.0-cp38-cp38-macosx_10_9_x86_64.whl (988.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

krb5-0.6.0-cp37-cp37m-macosx_10_9_x86_64.whl (989.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.6.0.tar.gz
  • Upload date:
  • Size: 230.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for krb5-0.6.0.tar.gz
Algorithm Hash digest
SHA256 712ba092fbe3a28ec18820bb1b1ed2cc1037b75c5c7033f970c6a8c97bbd1209
MD5 204783d4aba5268f0c281909839af2aa
BLAKE2b-256 dfc3a000ad6bd43b5859f5ec0bf1bb2a648d5f2c1928e59cd67e1d33585533c3

See more details on using hashes here.

Provenance

File details

Details for the file krb5-0.6.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce9d85d485cdaea78299fb2944871b92d1deb84f9e0d964411dce8e3e4039db7
MD5 47045e28d82ae9285c1d6939c1336ff6
BLAKE2b-256 712ffd502d896ce84e4b58c8fd4fd14290cf6024d6251c1bef3b651ea6d9a210

See more details on using hashes here.

Provenance

File details

Details for the file krb5-0.6.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.6.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8f1419ad4c4052f687aafd8ed0497de3e10905d7c4bfd0645d02fd63e24ab4b8
MD5 ae737bc5641eaf2d16c78fe85a402c5f
BLAKE2b-256 58886aa4042346c726cb01c29ac494db53176533261d9b2b254417f975cca5af

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3529bd2c0cb343fa3a0912445da5d307a1033c0a2686613449ba781f2e0b6a50
MD5 c7be44e5b939a32c7603fbba8d2ff88f
BLAKE2b-256 9146ccd1e20dd483c6251faeb8739bc84d76443366634581f82a23080717d901

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 62d803f989ea725479374447946f060fabcf74e956c4241b5e5316b2692e023a
MD5 f0b759681cc4cb8ef77647ecc9d85fec
BLAKE2b-256 8321916a8cda1b20b4f4d65e5b7e4bdbdb28b23d6366df77404131a5e0083882

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c89220495a1134dfe2d3566e31d7a44276ffdb20cda6f21257b311d41dae003
MD5 cc5f41ace2e95fb7a66077777504a15d
BLAKE2b-256 a4a3e9abada8f2a04e434b51be2029cda0501b72fdd5b28ad5b0c6a13b7aaeb8

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 61f4c0bf6a14c865f7a96b6647ae36c115d708e0f0e949e591fb8da17eb4b3f5
MD5 9d7d0663533ab2dad45d9b235f4e567b
BLAKE2b-256 d6ed98cf1c134cc64df004b1e01ea0dc4a41129ad29a96dc4827450d93347ae4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e34fd5976d6826e2f07bb23f7cd69a39b0efea13592ed42a9d4f3e07e40085c0
MD5 ec8b5d5476f131efb2561659ec8ad872
BLAKE2b-256 ce6e6267e854b15bc175d2686831c5b327c816779288cb33fa4855bf25ff7c8e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 324e21ebde6e7e08bcacc9f4ec1d3494c692002a15ba097ea042272f475b7a18
MD5 59c06778e525a30bf83424f3458e11a3
BLAKE2b-256 659f64ebbbe003b84e1c2829c9ae4d198585ed05bb31ca8c7466e0b409159523

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5af9eb068eb947e7ea90d8029feb340aa7ccd1795645f109100a9ffa4a9bb69
MD5 67d0de40cd074b4a5eb9a5395c9b0ce6
BLAKE2b-256 cd6e46abf0a54b48532bd4c98ca7c677afa515d2386a4e17f9881592cd45be12

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 174595bfd053df9fa2f9721cf41865756b0f6a6bc992e995e92ac604471e4542
MD5 fa237f77709f239890560f7eeb8c1695
BLAKE2b-256 412c29ff8bb02b580e06ea9b0877e25b8b276e236d841e85b4225b981ebbb4d6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.6.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c9cca6b40b98de2cfa715fa306578c63a9b7cb6f5b70881c47aaef4f93817991
MD5 3935281b65399a6c3d92f50cf6fe4fb5
BLAKE2b-256 d68e678ea8d3adfd2bcb2fbabbe038b1a4117e3eb31a769ad4b5b29a1989f786

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