Kerberos API bindings for Python
Reason this release was yanked:
0.1.0 was taken for the sdist
Project description
Python Kerberos 5 Library
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 thePATH
- FreeBSD will default to
/usr/local/bin/krb5-config
instead of/usr/bin/krb5-config
- The path to
KRB5_MAIN_LIB
- The path to the
libkrb5
shared library used to check if any of the optional functions are available
- The path to the
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for krb5-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05d923c637c008631138e7f83e300b889350fe2479f75967176be27d31af5199 |
|
MD5 | 1e67d0f903daccbd5fc1dbf8134d6c3a |
|
BLAKE2b-256 | 17331c7481e84b4ab1bed877170f3c52a2877405241216a99a62a1d42d49b6b1 |
Hashes for krb5-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9599b8a7bd574121a01408bec0d577c71b5ef5b471b5e71b30d6a6c421d4110b |
|
MD5 | 3fa9bda80c92d8be68423d2fed67a1a9 |
|
BLAKE2b-256 | 73d000bbe63401852d0abec856f9f837998502cee44e38bdfd30e2f6361ea12e |
Hashes for krb5-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b1b6c16d47ba702e621141d4364e30e62cd576a9978fe474019391d4645298 |
|
MD5 | 9f5fc1b0ce1c0b59b476f9c66bb80501 |
|
BLAKE2b-256 | 2cd0a7ea5ecd93ce643b8b9f5f7bf21e332d9a533d7bbbc06e5641c1eae8cc61 |
Hashes for krb5-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06518a36f6547bc38ec06478a1ff9a0d423940ff11831c824c2542325cd29412 |
|
MD5 | 3d3e0984a60a22c671fcf798b8d2ceda |
|
BLAKE2b-256 | 7727101c9caa341c2c4c3367f63a41a189bd19f84685a1e2ef5108a53d01e6ad |
Hashes for krb5-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b3eb5b774e67b8c89a04c9c1972315befa4b80ca9f2bebc5e82d7af6fc79a8b |
|
MD5 | 41d91b0c9e56dad92f1d0f7b012368ba |
|
BLAKE2b-256 | b332bc85fcc2a9b57eaea620f09117820365a8045c52d85c2dea45e91c46f30d |
Hashes for krb5-0.1.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90596db8ccd13590c47db95339c8814cd1e16e545794ebac6528c93bfe2694b2 |
|
MD5 | 4a60155f546dec2ec73173c009ecd671 |
|
BLAKE2b-256 | 74415ea316c52b46899710830a4eb1fe13912083e3c90d98939185a83de59f6f |