# Python Kerberos 5 Library
[![Test workflow](https://github.com/jborean93/pykrb5/actions/workflows/ci.yml/badge.svg)](https://github.com/jborean93/pykrb5/actions/workflows/ci.yml)
[![PyPI version](https://badge.fury.io/py/krb5.svg)](https://badge.fury.io/py/krb5)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jborean93/pykrb5/blob/main/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](https://github.com/pythongssapi/python-gssapi) which exposes the Kerberos authentication details through GSSAPI.
## Requirements
* An implementation of the Kerberos 5 API - including the header files
* [MIT Kebreros](https://web.mit.edu/kerberos/) - Minimum 1.17
* [Heimdal](https://github.com/heimdal/heimdal)
* 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:
```bash
pip install krb5
```
To install from source run the following:
```bash
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:
```bash
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](https://web.mit.edu/kerberos/krb5-devel/doc/appdev/refs/api/krb5_init_context.html) 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:
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/jborean93/pykrb5",
"name": "krb5",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "krb5, kerberos",
"author": "Jordan Borean",
"author_email": "jborean93@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/42/9a/a1eacfede9cb66fce3edb62ff62e8f296a64dabe1408a63e6666ceb4ced9/krb5-0.7.0.tar.gz",
"platform": null,
"description": "# Python Kerberos 5 Library\n\n[![Test workflow](https://github.com/jborean93/pykrb5/actions/workflows/ci.yml/badge.svg)](https://github.com/jborean93/pykrb5/actions/workflows/ci.yml)\n[![PyPI version](https://badge.fury.io/py/krb5.svg)](https://badge.fury.io/py/krb5)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jborean93/pykrb5/blob/main/LICENSE)\n\nThis library provides Python functions that wraps the Kerberos 5 C API.\nDue to the complex nature of this API it is highly recommended to use something like [python-gssapi](https://github.com/pythongssapi/python-gssapi) which exposes the Kerberos authentication details through GSSAPI.\n\n## Requirements\n\n* An implementation of the Kerberos 5 API - including the header files\n * [MIT Kebreros](https://web.mit.edu/kerberos/) - Minimum 1.17\n * [Heimdal](https://github.com/heimdal/heimdal)\n* A C compiler, such as GCC\n* Python 3.6+\n\n_Note: macOS includes their own implementation of Heimdal and a compiler isn't needed on that platform if installing from the wheel._\n\n## Installation\n\nSimply run:\n\n```bash\npip install krb5\n```\n\nTo install from source run the following:\n\n```bash\ngit clone https://github.com/jborean93/pykrb5.git\npython -m pip install build\npython -m build\npip install dist/krb5-*.whl\n```\n\nCompiling the code should automatically pick up the proper paths for the KRB5 headers and locations.\nIf further customisation is needed, the following environment variables can be set when building the wheel:\n\n* `KRB5_KRB5CONFIG`\n * The path to `krb5-config` to use for detecting the Kerberos library to link to\n * The compiler and linker args are derived from what this function outputs\n * Defaults to whatever `krb5-config` is on the `PATH`\n * FreeBSD will default to `/usr/local/bin/krb5-config` instead of `/usr/bin/krb5-config`\n* `KRB5_MAIN_LIB`\n * The path to the `libkrb5` shared library used to check if any of the optional functions are available\n* `KRB5_COMPILER_ARGS`\n * Compiler flags to use when compiling the extensions\n * Defaults to the output of `krb5-config --cflags krb5` if not set\n* `KRB5_LINKER_ARGS`\n * Linker flags to use when compiling the extensions\n * Defaults to the output of `krb5-config --libs krb5` if not set\n* `KRB5_SKIP_MODULE_CHECK`\n * Skips the checks used to detect if optional functions are available - will treat them all as available\n * This is only really useful when building the sdist as no implementation provides all these functions\n* `KRB5_CYTHON_TRACING`\n * Used to generate the Cython extensions with line tracing for coverage collection\n* `KRB5_MACOS_HEIMDAL_DIR`\n * Used when compiling on macOS to point to the Heimdal install directory\n * 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\n * Defaults to `{git_root}/build_helpers/heimdal`\n\n## Development\n\nTo run the tests or make changes to this repo run the following:\n\n```bash\ngit clone https://github.com/jborean93/pykrb5.git\npip install -r requirements-dev.txt\npre-commit install\n\npython -m pip install -e .\n\n# Can compile the krb5 extensions on an adhoc basis\n# python setup.py build_ext --inplace\n```\n\nFrom there an editor like VSCode can be used to make changes and run the test suite.\nTo recompile the Cython files after a change run the `build_ext --inplace` command.\n\n## Structure\n\nThis library is merely a wrapper around the Kerberos 5 APIs.\nThe functions under the `krb5` namespace match the KRB5 API specification but with the `krb5_` prefix remove.\nFor example the [krb5_init_context](https://web.mit.edu/kerberos/krb5-devel/doc/appdev/refs/api/krb5_init_context.html) function is called through `krb5.init_context()`.\nErrors are raised as a `Krb5Error` which contains the message as formatted by the KRB5 implementation and the error code for that error.\nSome 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.\nSome classes expose an `addr` property that returns the raw pointer address of the structure it is wrapping.\nThis 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.\n\nNot all the functions exposed in this library are available on every KRB5 API implementation.\nTo check if a function is available run the following:\n\n```python\nimport krb5\n\nif not hasattr(krb5, \"kt_dup\"):\n raise Exception(\"Current implementation does not support krb5_kt_dup\")\n```\n\nThere may also be some difference in behaviour, error codes, error messages, between te different implementations.\nIt is up to the caller to paper over these differences when required.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Kerberos API bindings for Python",
"version": "0.7.0",
"project_urls": {
"Homepage": "https://github.com/jborean93/pykrb5"
},
"split_keywords": [
"krb5",
" kerberos"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cd60e8d6c83af41cdd3d75bf05da3e2cc949417d5de8d8f4b4a7eaf54776ffda",
"md5": "455675514549aa7a8eda35f67ed2ec54",
"sha256": "69dc98084de5d693a97725f746d5af46299590bb9658c9fc32e4769a4a0f3079"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "455675514549aa7a8eda35f67ed2ec54",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 1075046,
"upload_time": "2024-10-03T06:29:52",
"upload_time_iso_8601": "2024-10-03T06:29:52.163614Z",
"url": "https://files.pythonhosted.org/packages/cd/60/e8d6c83af41cdd3d75bf05da3e2cc949417d5de8d8f4b4a7eaf54776ffda/krb5-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a31b28cdd6ed4db73c9670b8d199fc73310d347a065419aa078744fce7cb797a",
"md5": "8c0455625ba54a78bb0f66451beffe8d",
"sha256": "4a32a35e425ce967f5577f9247a4e0a7d7e9a7e4527a778f7e0719aeb99e295f"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "8c0455625ba54a78bb0f66451beffe8d",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 1014259,
"upload_time": "2024-10-03T06:29:53",
"upload_time_iso_8601": "2024-10-03T06:29:53.599322Z",
"url": "https://files.pythonhosted.org/packages/a3/1b/28cdd6ed4db73c9670b8d199fc73310d347a065419aa078744fce7cb797a/krb5-0.7.0-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "137070c871e2254a1337336e2f04004c8fd83694fee2b3de5ccefe5470402a9e",
"md5": "3f8f8c733dfdc71e8444317ff5de95a4",
"sha256": "717e5b8b4d78268eefdba72a39cb0f93e5821a23e626ada3a45a583a2454d084"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "3f8f8c733dfdc71e8444317ff5de95a4",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 1074031,
"upload_time": "2024-10-03T06:29:54",
"upload_time_iso_8601": "2024-10-03T06:29:54.883776Z",
"url": "https://files.pythonhosted.org/packages/13/70/70c871e2254a1337336e2f04004c8fd83694fee2b3de5ccefe5470402a9e/krb5-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "abd45e7ccdeb2b1fa872daf03fbbd00476957bca3f388dfdf770122c2cbbb835",
"md5": "b7c3ed937d22fe621aae35b2cbda7df9",
"sha256": "66b286d9b4af42b4f5d2d561354cd44d891bee275768f1a2ac795ad4e8042dce"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "b7c3ed937d22fe621aae35b2cbda7df9",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 1013821,
"upload_time": "2024-10-03T06:29:56",
"upload_time_iso_8601": "2024-10-03T06:29:56.094203Z",
"url": "https://files.pythonhosted.org/packages/ab/d4/5e7ccdeb2b1fa872daf03fbbd00476957bca3f388dfdf770122c2cbbb835/krb5-0.7.0-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2f09779082321824a9ebe0ee2d51f19a84c8f12425441572bda90d86674958c9",
"md5": "86a9368e67f6bbe479b38a58a631c20f",
"sha256": "fa4ea45629e585787c0bcc455c7fbed7e09176031a7f9e7c87b9deaad401da36"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl",
"has_sig": false,
"md5_digest": "86a9368e67f6bbe479b38a58a631c20f",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 1085455,
"upload_time": "2024-10-03T06:29:58",
"upload_time_iso_8601": "2024-10-03T06:29:58.635348Z",
"url": "https://files.pythonhosted.org/packages/2f/09/779082321824a9ebe0ee2d51f19a84c8f12425441572bda90d86674958c9/krb5-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "315e911ff98bcf57dd47abe17adfa22279ed17d23ea3baabb72b9f3bc29cf17f",
"md5": "bdb5125c6ca628889d71214fa8ae703c",
"sha256": "a33896483f6d415c4289e5cc108b0450a919bae0546a997f3352d982bd4e7c99"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp312-cp312-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "bdb5125c6ca628889d71214fa8ae703c",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 1024601,
"upload_time": "2024-10-03T06:30:01",
"upload_time_iso_8601": "2024-10-03T06:30:01.024482Z",
"url": "https://files.pythonhosted.org/packages/31/5e/911ff98bcf57dd47abe17adfa22279ed17d23ea3baabb72b9f3bc29cf17f/krb5-0.7.0-cp312-cp312-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d1c29aeeca5738f99735f9755c2ccd378573bcea02a72675a089a30ab26117be",
"md5": "f9363f2315c5bcf880b7dae386ffc867",
"sha256": "87a6d11bb182a289dd86086c19cba3f03a8108175e8e23292d3d2786ff3ecaeb"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp313-cp313-macosx_10_13_x86_64.whl",
"has_sig": false,
"md5_digest": "f9363f2315c5bcf880b7dae386ffc867",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.8",
"size": 1076764,
"upload_time": "2024-10-03T06:30:02",
"upload_time_iso_8601": "2024-10-03T06:30:02.826301Z",
"url": "https://files.pythonhosted.org/packages/d1/c2/9aeeca5738f99735f9755c2ccd378573bcea02a72675a089a30ab26117be/krb5-0.7.0-cp313-cp313-macosx_10_13_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b34961960e224a51301b26a13171cea44b0fa30604fd02f225846d6974ed02e",
"md5": "4cc5ab6b4d3ad1fe9105c78a5321626c",
"sha256": "691e2eafd0b16cb1b209b2bd36888526ea7df24ce69ba39e72ccad281ffdadb2"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp313-cp313-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "4cc5ab6b4d3ad1fe9105c78a5321626c",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.8",
"size": 1017250,
"upload_time": "2024-10-03T06:30:04",
"upload_time_iso_8601": "2024-10-03T06:30:04.551351Z",
"url": "https://files.pythonhosted.org/packages/7b/34/961960e224a51301b26a13171cea44b0fa30604fd02f225846d6974ed02e/krb5-0.7.0-cp313-cp313-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9bbfd99f47c907463caf472be5c02f30bcd44803d04bed17023b6ccc0d1e04ca",
"md5": "183f1ab580a8d607c52c8bcef626cb96",
"sha256": "dd954a76973ddc295756a5741e7fcfda70cfd31d965d45ed47422bffe5792b6f"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "183f1ab580a8d607c52c8bcef626cb96",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 1077613,
"upload_time": "2024-10-03T06:30:06",
"upload_time_iso_8601": "2024-10-03T06:30:06.396399Z",
"url": "https://files.pythonhosted.org/packages/9b/bf/d99f47c907463caf472be5c02f30bcd44803d04bed17023b6ccc0d1e04ca/krb5-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4e13fbdb1a9f5f7331fe44d66fdac11a49f937d088a51282974cb3ece7cf9cff",
"md5": "06b84294b8c311bfeb0b836600e707e4",
"sha256": "aead8037a4ef3f8a12db09fec32ff7f561399a35970c40bf62d748b834ac0eb5"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp38-cp38-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "06b84294b8c311bfeb0b836600e707e4",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 1016493,
"upload_time": "2024-10-03T06:30:07",
"upload_time_iso_8601": "2024-10-03T06:30:07.912437Z",
"url": "https://files.pythonhosted.org/packages/4e/13/fbdb1a9f5f7331fe44d66fdac11a49f937d088a51282974cb3ece7cf9cff/krb5-0.7.0-cp38-cp38-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1e7269045d475f394b64ca29af802f5e7361d81bab1ba23efe58294870849042",
"md5": "ff9989c8413b3f9931f767f783fca911",
"sha256": "72d551ce659502f3a7c46c65cdd75af682c077d3d1a081d4d1bb478e14a55ffd"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "ff9989c8413b3f9931f767f783fca911",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 1080773,
"upload_time": "2024-10-03T06:30:10",
"upload_time_iso_8601": "2024-10-03T06:30:10.084953Z",
"url": "https://files.pythonhosted.org/packages/1e/72/69045d475f394b64ca29af802f5e7361d81bab1ba23efe58294870849042/krb5-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "123802abf5401dcd782dab38fab52cb2c75ad4726a5b319a9ed42499dfef70a5",
"md5": "37e154fee1f634bbcb9272e8a4fce9e3",
"sha256": "f2cef1a7f78d331cc07b69cb8dc4cfb4a80f7b11dc2949f4e81f8cf86fd1836a"
},
"downloads": -1,
"filename": "krb5-0.7.0-cp39-cp39-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "37e154fee1f634bbcb9272e8a4fce9e3",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 1019470,
"upload_time": "2024-10-03T06:30:11",
"upload_time_iso_8601": "2024-10-03T06:30:11.620249Z",
"url": "https://files.pythonhosted.org/packages/12/38/02abf5401dcd782dab38fab52cb2c75ad4726a5b319a9ed42499dfef70a5/krb5-0.7.0-cp39-cp39-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "429aa1eacfede9cb66fce3edb62ff62e8f296a64dabe1408a63e6666ceb4ced9",
"md5": "2c707f2fd06826ab6680a92b889f8de6",
"sha256": "6a308f2e17d151c395b24e6aec7bdff6a56fe3627a32042fc86d412398a92ddd"
},
"downloads": -1,
"filename": "krb5-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "2c707f2fd06826ab6680a92b889f8de6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 235693,
"upload_time": "2024-10-03T06:30:13",
"upload_time_iso_8601": "2024-10-03T06:30:13.174867Z",
"url": "https://files.pythonhosted.org/packages/42/9a/a1eacfede9cb66fce3edb62ff62e8f296a64dabe1408a63e6666ceb4ced9/krb5-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-03 06:30:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jborean93",
"github_project": "pykrb5",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "krb5"
}