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

Uploaded Source

Built Distributions

krb5-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (718.2 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

krb5-0.5.0-cp311-cp311-macosx_10_9_x86_64.whl (791.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

krb5-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (726.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

krb5-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl (796.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

krb5-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (737.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

krb5-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl (812.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

krb5-0.5.0-cp38-cp38-macosx_11_0_arm64.whl (719.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

krb5-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl (792.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

krb5-0.5.0-cp37-cp37m-macosx_10_9_x86_64.whl (794.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for krb5-0.5.0.tar.gz
Algorithm Hash digest
SHA256 33d6cf20ff9710cffb883136387fabc906360de1bce58bcd5673c4bb420e1657
MD5 bc99fbfb18a9ecce4dd48218b547ef7f
BLAKE2b-256 58e350ce47968c1ae283b99410ebb6eaa595b2f016f35f15a9d11426db65ae3e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31603913a068c148639d62c9aada9f51ddeb4ba77594c2d9857fbdfe6824376e
MD5 a5951b7ffb51093ace679d2882d582af
BLAKE2b-256 f0183ace9f937d358671a2b65e3a3f7c79af7cfc419cf0115d88a01dfb33ac4f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a9609198ba4aa35586c1ceb55171c113434eedcc97187a9f743be32c4831115f
MD5 b7d8df4fd29ca11f07dbd6bc39440c9f
BLAKE2b-256 dfa7b51b162219155eb858c9d8353f227f71e2228c018d599043177fc639ff21

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 939ba0fe5dd56eefb666485adc115216c034711c2ecf7a76f7a42864c2831a8c
MD5 43ffe0fff5742c205c6c79edca217b67
BLAKE2b-256 64d9a28b9dfbcdba55432720fd29a21e94318ef253b9ab70cdfb586507ce79ca

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 db6d5dada48a2e14793e3e61213fae5de3787c4f3d74dcb744ef8bf3a87afa96
MD5 87069a4993f6b3641838fb2fdedec5c2
BLAKE2b-256 581e380b15c72ef9e75c01352d80421108fa7f6155fe3f9c6e52de4962c09662

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e1ae1c1b114817a7fd12c6427688a00b9bc8fc3b9896efd455f513d8d3e1111
MD5 cce68ab67f1c058c8c5c7d9690b6d6a9
BLAKE2b-256 bcf0220c340ab5dc1f949f40d5ec3674f5faf87f12bd71cee1876ef69c94b8b2

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3112879e5f77cd7f404c61552fceb9c8745cb330086db822289e10fd68911f33
MD5 ca44106f9313d5f962ea8b971ac38400
BLAKE2b-256 b9838ad161ca9afa71b345a6af5d5c2613bf1f66c2ff1892a85c300d7eb14f13

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfd76ea4e4aee06a23da7cbec1c50452cf0388f05fd63fac71b14b4a9474c250
MD5 f869b90652ffa179688122a6a5025d2f
BLAKE2b-256 ea36466e81cba9c7a68ccae2916a5f3ab78a9b89415c111d2bcf229233fbb1a1

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e0a9debe7402ddb06f8b15d10da5894ae536317b80b95bb2393e916fd7e807b1
MD5 afe786ed8da5ed7aff0b18ef95642aa4
BLAKE2b-256 f252fce96ce9d71bdb788341b6f503a645254b2451fcc337be56fa02e93cdcc3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for krb5-0.5.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8221f288dc993013097257f0cc612132a07b414e0c5dc69396387c13e07e369e
MD5 cb2611b3f8ac33ff2678c3a57e832bea
BLAKE2b-256 ac64e578a981a07c60fe730689f8f1c71dd6c1626f5437c531a03a806cc0daa5

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