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

Uploaded Source

Built Distributions

krb5-0.7.1-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

krb5-0.7.1-cp313-cp313-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

krb5-0.7.1-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

krb5-0.7.1-cp312-cp312-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

krb5-0.7.1-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

krb5-0.7.1-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

krb5-0.7.1-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

krb5-0.7.1-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

krb5-0.7.1-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

krb5-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

krb5-0.7.1-cp38-cp38-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

krb5-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: krb5-0.7.1.tar.gz
  • Upload date:
  • Size: 235.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.7.1.tar.gz
Algorithm Hash digest
SHA256 ed5f13d5031489b10d8655c0ada28a81c2391b3ecb8a08c6d739e1e5835bc450
MD5 10d6e5a3813a354369555cd8d3e5ad24
BLAKE2b-256 6f24eb49e51fdbbfb360f58159cb08bc1925403b72cefb49fad57745fd2f42a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1.tar.gz:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file krb5-0.7.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for krb5-0.7.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7590317af8c9633e420f90d112163687dbdd8fc9c3cee6a232d6537bcb5a65c3
MD5 9bb381ba6cdde1f7b7bd01eb1521a922
BLAKE2b-256 3e312ba8492220d2ff95f0c660efabcbd20c19004227761fa6055d933d956fd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file krb5-0.7.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3c4c2c5b48f7685a281ae88aabbc7719e35e8af454ea812cf3c38759369c7aac
MD5 fbc2e4211b299291456eff84577486ea
BLAKE2b-256 7af7070c2147256eaf367b47dee581f01e3442e74565b1cf54443cb8c4687473

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for krb5-0.7.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af1932778cd462852e2a25596737cf0ae4e361f69e892b6c3ef3a29c960de3a0
MD5 72820231ba23099626d543f5fd1ccede
BLAKE2b-256 46baa844887911c4c7c5ee46063d675e87430bd8fe4ff2f37858ff1a3c2fb949

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file krb5-0.7.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for krb5-0.7.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a075da3721b188070d801814c58652d04d3f37ccbf399dee63251f5ff27d2987
MD5 4fb3581c2db41717d3be031363f842a8
BLAKE2b-256 06b9cf7b3151e5a146ed6ee809e497075b8e40fdac448d60fdc1dd8d92251014

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for krb5-0.7.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af6eedfe51b759a8851c41e67f7ae404c382d510b14b626ec52cca564547a7f7
MD5 261593c212af2af49690ea822ac66dd7
BLAKE2b-256 e8880cdbc09c221387a7208595f8ead266163d65a43be96495aebf6b3f5971bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for krb5-0.7.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8f503ec4b44dedb6bfe49b636d5e4df89399b27a1d06218a876a37d5651c5ab3
MD5 d0015c817e7116874293a19513f480c5
BLAKE2b-256 fd0e7ccc328494da7f1ff94226a954f98d97958c09292325a3d2ab3a78482d08

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for krb5-0.7.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40ad837d563865946cffd65a588f24876da2809aa5ce4412de49442d7cf11d50
MD5 89d66acac781d7ceee19a9f87d084d4b
BLAKE2b-256 eb590d58bded4d5f23dca5a9e7ea9f998b815ce86db2577fbbaf3a0cfbbe5fb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for krb5-0.7.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cbdcd2c4514af5ca32d189bc31f30fee2ab297dcbff74a53bd82f92ad1f6e0ef
MD5 c41ecc1fbd793fff0116b01f14896d82
BLAKE2b-256 48dbc38dd29bd1fc661350db446d08a0f2ff69fc94e168e020e9e43e9141fe49

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: krb5-0.7.1-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.7.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9b71148b8974fc032268df23643a4089677dc3d53b65167e26e1e72eaf43204
MD5 e78e3bc40b9ee0faad994a32e758d046
BLAKE2b-256 bcf28baa2a86b7cb6e5da432e2810b26b4cd602a4029a9430a558a3d00cdf176

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: krb5-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 44045e1f8a26927229eedbf262d3e8a5f0451acb1f77c3bd23cad1dc6244e8ad
MD5 cf5d496f440c61453d60391d1e5df59f
BLAKE2b-256 5c8d05664b2ae6963833b06f10cf57ab585a394969228ce1fee9adc07beb0a38

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: krb5-0.7.1-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.7.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c8c1d5967a910562dbffae74bdbe8a364d78a6cecce0a429ec17776d4729e74
MD5 d95113183be164f1ff85387b58d5fe04
BLAKE2b-256 ea1a96ffff80e5f0409e0ffff03fdf650191b53aa3937c5fa73450730bb05e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp38-cp38-macosx_11_0_arm64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: krb5-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for krb5-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 87a592359cc545d061de703c164be4eabb977e3e8cae1ef0d969fadc644f9df6
MD5 5376179bdfd284f213bb3adf605a4966
BLAKE2b-256 dac4989f1dc4c7457910bbae5cfc51beb19018621c1c21bde5603b8e0299a7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for krb5-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl:

Publisher: ci.yml on jborean93/pykrb5

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page