Skip to main content

WinKerberos

Info:

See github for the latest source.

Author:

Bernie Hackett <bernie@mongodb.com>

About

A native Kerberos client implementation for Python on Windows. This module mimics the API of pykerberos to implement Kerberos authentication with Microsoft’s Security Support Provider Interface (SSPI). It supports Python 3.8+.

Installation

WinKerberos is in the Python Package Index (pypi). Use pip to install it:

python -m pip install winkerberos

WinKerberos requires Windows 7 / Windows Server 2008 R2 or newer.

Building and installing from source

You must have the correct version of VC++ installed for your version of Python:

  • Python 3.8+ - Visual Studio 2015+ (Any version)

Once you have the required compiler installed, run the following command from the root directory of the WinKerberos source:

pip install .

Building HTML documentation

First install Sphinx:

python -m pip install Sphinx

Then run the following command from the root directory of the WinKerberos source:

pip install -e .
python -m sphinx -b html doc doc/_build

Examples

This is a simplified example of a complete authentication session following RFC-4752, section 3.1:

import winkerberos as kerberos


def send_response_and_receive_challenge(response):
    # Your server communication code here...
    pass


def authenticate_kerberos(service, user, channel_bindings=None):
    # Initialize the context object with a service principal.
    status, ctx = kerberos.authGSSClientInit(service)

    # GSSAPI is a "client goes first" SASL mechanism. Send the
    # first "response" to the server and receive its first
    # challenge.
    if channel_bindings is not None:
        status = kerberos.authGSSClientStep(ctx, "", channel_bindings=channel_bindings)
    else:
        status = kerberos.authGSSClientStep(ctx, "")
    response = kerberos.authGSSClientResponse(ctx)
    challenge = send_response_and_receive_challenge(response)

    # Keep processing challenges and sending responses until
    # authGSSClientStep reports AUTH_GSS_COMPLETE.
    while status == kerberos.AUTH_GSS_CONTINUE:
        if channel_bindings is not None:
            status = kerberos.authGSSClientStep(
                ctx, challenge, channel_bindings=channel_bindings
            )
        else:
            status = kerberos.authGSSClientStep(ctx, challenge)

        response = kerberos.authGSSClientResponse(ctx) or ""
        challenge = send_response_and_receive_challenge(response)

    # Decrypt the server's last challenge
    kerberos.authGSSClientUnwrap(ctx, challenge)
    data = kerberos.authGSSClientResponse(ctx)
    # Encrypt a response including the user principal to authorize.
    kerberos.authGSSClientWrap(ctx, data, user)
    response = kerberos.authGSSClientResponse(ctx)

    # Complete authentication.
    send_response_and_receive_challenge(response)

Channel bindings can be generated with help from the cryptography module. See https://tools.ietf.org/html/rfc5929#section-4.1 for the rules regarding hash algorithm choice:

from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes


def channel_bindings(ssl_socket):
    server_certificate = ssl_socket.getpeercert(True)
    cert = x509.load_der_x509_certificate(server_certificate, default_backend())
    hash_algorithm = cert.signature_hash_algorithm
    if hash_algorithm.name in ("md5", "sha1"):
        digest = hashes.Hash(hashes.SHA256(), default_backend())
    else:
        digest = hashes.Hash(hash_algorithm, default_backend())
    digest.update(server_certificate)
    application_data = b"tls-server-end-point:" + digest.finalize()
    return kerberos.channelBindings(application_data=application_data)

Viewing API Documentation without Sphinx

Use the help function in the python interactive shell:

>>> import winkerberos
>>> help(winkerberos)

Metadata

Release files for winkerberos 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for winkerberos 0.11.0
File Size Uploaded Provenance Actions
winkerberos-0.11.0.tar.gz 35.6 kB Without provenance Details for winkerberos-0.11.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for winkerberos 0.11.0
File Actions
winkerberos-0.11.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for winkerberos-0.11.0-cp312-cp312-win_amd64.whl
winkerberos-0.11.0-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details for winkerberos-0.11.0-cp312-cp312-win32.whl
winkerberos-0.11.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for winkerberos-0.11.0-cp311-cp311-win_amd64.whl
winkerberos-0.11.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details for winkerberos-0.11.0-cp311-cp311-win32.whl
winkerberos-0.11.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for winkerberos-0.11.0-cp310-cp310-win_amd64.whl
winkerberos-0.11.0-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details for winkerberos-0.11.0-cp310-cp310-win32.whl
winkerberos-0.11.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for winkerberos-0.11.0-cp39-cp39-win_amd64.whl
winkerberos-0.11.0-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details for winkerberos-0.11.0-cp39-cp39-win32.whl
winkerberos-0.11.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for winkerberos-0.11.0-cp38-cp38-win_amd64.whl
winkerberos-0.11.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details for winkerberos-0.11.0-cp38-cp38-win32.whl

Total release size: 300.3 kB

Release files / winkerberos-0.11.0.tar.gz

Download URL winkerberos-0.11.0.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
472632ce2bd0086e408ccd481ecc0f41e442d48076f3a240fba546af0022e50d
BLAKE2b-256 checksum
How to use checksums
2803852906880e86bafe017ac99f5260cb8c29c28fe7acb45ca261e62705f405
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp312-cp312-win_amd64.whl

Download URL winkerberos-0.11.0-cp312-cp312-win_amd64.whl
Size 27.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
52068fded003214c51084d98f5b3d8c43400eea190afd151fd2f480e9d2c571f
BLAKE2b-256 checksum
How to use checksums
5312d4096c313833f15d561b648b5157f8e15b1da0c2a9b2ac650d060a4ed338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp312-cp312-win32.whl

Download URL winkerberos-0.11.0-cp312-cp312-win32.whl
Size 25.4 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
546bbd9d83f0eeac7df1f9634c4c6865176fd624f41032dfa98e25420a161d7f
BLAKE2b-256 checksum
How to use checksums
7406b9d9a8ba334d264061cf34d20c81ca08fea09dd520edb2b9c3b2ca8df4d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp311-cp311-win_amd64.whl

Download URL winkerberos-0.11.0-cp311-cp311-win_amd64.whl
Size 27.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
07a6f24a6c0da5e8a91cbd8c5f28b1a4ac68dcea3b73d43b036a697637b0c9a6
BLAKE2b-256 checksum
How to use checksums
7dd4174bf165754df8fb858ff08ca087df50c2f9cdf6e800ffb09a9a8e8f497f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp311-cp311-win32.whl

Download URL winkerberos-0.11.0-cp311-cp311-win32.whl
Size 25.3 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
89a5572438aab17d51da75eb1101ea7183142869e3c69b23ebad4395a78a1bd2
BLAKE2b-256 checksum
How to use checksums
492f0964f68fc7f8ba19754352b88bf08d0da589b5332a3782f89c00eaecd73b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp310-cp310-win_amd64.whl

Download URL winkerberos-0.11.0-cp310-cp310-win_amd64.whl
Size 27.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d9545356f438eb9de7e7196bd8cda7a8e3ab19a083951fec7c612b88a67d1e98
BLAKE2b-256 checksum
How to use checksums
1d7c69f26f1d51ff543003c05984ee2e387a569a2857d0e3a49830d2d5436f51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp310-cp310-win32.whl

Download URL winkerberos-0.11.0-cp310-cp310-win32.whl
Size 25.3 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
cba83a4ad65d1ccba2b34476eded7564e94da390ab6ee240aab7ee8f856fd61e
BLAKE2b-256 checksum
How to use checksums
bdddd8d9ad427549537eae4bc175e685e285e0a8c32d9442e64e78e38397d52c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp39-cp39-win_amd64.whl

Download URL winkerberos-0.11.0-cp39-cp39-win_amd64.whl
Size 27.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
62f66075f9122bb13dadd2da33365177ccd4f41258f9410fba79d06402086db6
BLAKE2b-256 checksum
How to use checksums
19734efdaa2b1ec868e235516d0db8dbb1e43a8b79c5c1f0a3e5f58c484039cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp39-cp39-win32.whl

Download URL winkerberos-0.11.0-cp39-cp39-win32.whl
Size 25.3 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
e03139558e3451d6971219ca49873e77e2f99871f8b2f0b0577bb616022f782a
BLAKE2b-256 checksum
How to use checksums
fd7d21104f225ca0e1641d895864440ad0f24a605d2b83b179e2779feee4f2cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp38-cp38-win_amd64.whl

Download URL winkerberos-0.11.0-cp38-cp38-win_amd64.whl
Size 27.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
77282f7bbbf593b7bdf2c708ddef0f95be3d9e9dfc5e0e49a9e9ce233f427319
BLAKE2b-256 checksum
How to use checksums
28c0a28e225a707751ea9983f63763599633cc90a683ba9bbb3c60b014fd24e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / winkerberos-0.11.0-cp38-cp38-win32.whl

Download URL winkerberos-0.11.0-cp38-cp38-win32.whl
Size 25.3 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
23f7711086bbce1e12991d04978a4b5ae9061ae5c717329ef8c46331d84a1114
BLAKE2b-256 checksum
How to use checksums
31f5ef4ea2b0041a2a6b3b3ac0bad95962264ce13537896766e7125283eaa04c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Security for winkerberos 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page