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.4.0.tar.gz (218.8 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.0-cp310-cp310-macosx_11_0_arm64.whl (714.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

krb5-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl (780.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

krb5-0.4.0-cp39-cp39-macosx_11_0_arm64.whl (724.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

krb5-0.4.0-cp39-cp39-macosx_10_9_x86_64.whl (795.0 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

krb5-0.4.0-cp38-cp38-macosx_11_0_arm64.whl (707.5 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

krb5-0.4.0-cp38-cp38-macosx_10_9_x86_64.whl (775.5 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

krb5-0.4.0-cp37-cp37m-macosx_10_9_x86_64.whl (777.4 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for krb5-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6eb0e91e044d37cb34c84b831310f4a48951f2902d4ebb65b97cbac5ff1b2264
MD5 677b3d81d773b1097d1020347e387efc
BLAKE2b-256 30b2fbafed4fe18a47bc3ffdd7a591bc02c4cf9e96d092793831cb98d596fa16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e679e0fe099ca8024068694087f91d5e0c0e1349fc6ad6e10efe5156faebcc8e
MD5 02a45aa97a87d5b540deeb5b8cefbc5a
BLAKE2b-256 aa4d15b475385014025885100ff320029455474a932bb17e3bc5d6eaacbeb9c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d808d499edeb8604d1445e8b8e9f6daf4b639a3793ed6e21dacaf46e7eb2d037
MD5 b3ae1629ba9dc6115434ed7f54ef0004
BLAKE2b-256 7fcfe19219334c61aed0ef651733b0426086fb8f28c3bedfcb55a7e9cd2b719b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for krb5-0.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 377fc48d4224235b10b1f3afc7ba4104c00e749a5086f04efb24d48b61121aae
MD5 a96b7835eaeeb406cb64a7b0be8f8659
BLAKE2b-256 95902df89afc629d17396996076ec938377417b9774e09a2c84f5de1f3f78148

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krb5-0.4.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 795.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.13

File hashes

Hashes for krb5-0.4.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0bf7eecc4e8ca85bc3958d304d1fe06a174b20d10327a7b3e8038b9e24bb23f4
MD5 3ee0104d991de3ebd26f4fbd4dad9850
BLAKE2b-256 fd2d0ecdaa3e24af7f7cdddf3512ff0900c8401830b7a21d3765770132f7db35

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for krb5-0.4.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3fe44118c88a2ef2a198937fc31bd2cff07ec32a0f39d1ec62d263c02b62782
MD5 e2f00b9c41857b2ea9ec22ef930e378b
BLAKE2b-256 48f09d7eedca3e28f263262288eb1c5cd052f9af2791fbb6953cdfe32a7893d6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for krb5-0.4.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 36bcfe7ac9a215d619ef26ba87a31a51b036335b0852a34f84cc741f15ef340f
MD5 e688b8a216c19079c47b69f15d9cc1f4
BLAKE2b-256 c37bd0fc0ff41cf3bc4eade230ed3996fbf6fdc25e22e347cce502edb91f72b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krb5-0.4.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5ed97ade612a1bae6c7ef3c2fa109c6291fc1b4d52ad65acae657fe01a4eb3ab
MD5 204c05b2e884d9b5540dd958ab2276a7
BLAKE2b-256 686ad05a08fb2623f47cd47955da20fd9516ae44d7af1fab9e980f2f2eef1fa2

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 Pingdom Monitoring Sentry Error logging StatusPage Status page