Package: krb5
Python Kerberos 5 LibraryThis 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 likepython-gssapiwhich exposes the Kerberos authentication details through GSSAPI.RequirementsAn implementation of the Kerberos 5 API - including the header filesMIT KebrerosHeimdalA C compiler, such as GCCPython 3.6+Note: macOS includes their own implementation of Heimdal and a compiler isn't needed on that platform if installing from the wheel.InstallationSimply run:pipinstallkrb5To install from source run the following:gitclonehttps://github.com/jborean93/pykrb5.git
python-mpipinstallbuild
python-mbuild
pipinstalldist/krb5-*.whlCompiling 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_KRB5CONFIGThe path tokrb5-configto use for detecting the Kerberos library to link toThe compiler and linker args are derived from what this function outputsDefaults to whateverkrb5-configis on thePATHFreeBSD will default to/usr/local/bin/krb5-configinstead of/usr/bin/krb5-configKRB5_MAIN_LIBThe path to thelibkrb5shared library used to check if any of the optional functions are availableKRB5_COMPILER_ARGSCompiler flags to use when compiling the extensionsDefaults to the output ofkrb5-config --cflags krb5if not setKRB5_LINKER_ARGSLinker flags to use when compiling the extensionsDefaults to the output ofkrb5-config --libs krb5if not setKRB5_SKIP_MODULE_CHECKSkips the checks used to detect if optional functions are available - will treat them all as availableThis is only really useful when building the sdist as no implementation provides all these functionsKRB5_CYTHON_TRACINGUsed to generate the Cython extensions with line tracing for coverage collectionKRB5_MACOS_HEIMDAL_DIRUsed when compiling on macOS to point to the Heimdal install directoryUsed to find the Heimdal header files as macOS does not include, or provide a way to obtain, these header files for their Heimdal frameworkDefaults to{git_root}/build_helpers/heimdalDevelopmentTo run the tests or make changes to this repo run the following:gitclonehttps://github.com/jborean93/pykrb5.git
pipinstall-rrequirements-dev.txt
pre-commitinstall

python-mpipinstall-e.# Can compile the krb5 extensions on an adhoc basis# python setup.py build_ext --inplaceFrom 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 thebuild_ext --inplacecommand.StructureThis library is merely a wrapper around the Kerberos 5 APIs.
The functions under thekrb5namespace match the KRB5 API specification but with thekrb5_prefix remove.
For example thekrb5_init_contextfunction is called throughkrb5.init_context().
Errors are raised as aKrb5Errorwhich 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 anaddrproperty that returns the raw pointer address of the structure it is wrapping.
This is so the structure can be used in other libraries likepython-gssapibut 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:importkrb5ifnothasattr(krb5,"kt_dup"):raiseException("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.