Skip to main content
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 2.7 and 3.5+.

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:

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

python setup.py 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:

python setup.py doc

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 recieve 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.9.1

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.9.1
File Size Uploaded
winkerberos-0.9.1.zip 44.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for winkerberos 0.9.1
File
winkerberos-0.9.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
winkerberos-0.9.1-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
winkerberos-0.9.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
winkerberos-0.9.1-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
winkerberos-0.9.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
winkerberos-0.9.1-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
winkerberos-0.9.1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
winkerberos-0.9.1-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
winkerberos-0.9.1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
winkerberos-0.9.1-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
winkerberos-0.9.1-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
winkerberos-0.9.1-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
winkerberos-0.9.1-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
winkerberos-0.9.1-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
winkerberos-0.9.1-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
winkerberos-0.9.1-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details

Total release size: 406.3 kB

Release files / winkerberos-0.9.1.zip

Download URL winkerberos-0.9.1.zip
Size 44.0 kB
Tags Source
SHA-256 checksum
How to use checksums
02ec925c2aa4fe4f7656792a76e346d8fab13e12ced2732354a21958adfe92c6
BLAKE2b-256 checksum
How to use checksums
aaceddd1aa02552c876df8efc4710ced6148c749df8276705f8e94f84fcb0561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp311-cp311-win_amd64.whl
Size 23.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
60e47a551db0431a2e98b46ef9d9b59a70df0c0c450af0172747da7083573122
BLAKE2b-256 checksum
How to use checksums
834cd8cb38ad905b112065363bbcd625a6edb2f35da9d529379caf264ea1db82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp311-cp311-win32.whl
Size 21.3 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
26716c91900f19c8990d6e77026e1b1686e5bdb22ac829c87781ff80eba4603d
BLAKE2b-256 checksum
How to use checksums
b7b23381cd9c5c756d9da6d836429fbf7fb558d7db402d56abf9b52d7dfb04c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp310-cp310-win_amd64.whl
Size 23.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
59499e9682961ea784fa41b85af499b699f2ff5f3a07fde30a51ce33d509fa96
BLAKE2b-256 checksum
How to use checksums
c3ecaaf4ca160bdf5752d8edbe8978ba362e21fd7b4d93a40b6090822c1f9b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp310-cp310-win32.whl
Size 21.3 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
4565476111ec30a9def8f4c31bb937e165ab9862ad11ffa700f431f0d4941030
BLAKE2b-256 checksum
How to use checksums
3063c49029c8afe6b6f94a9d51fda87d9be63bde7f233f7aa67db18b0146edbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp39-cp39-win_amd64.whl
Size 23.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
9842854fa5527b72720e2911f1b6008736baacaf3df1a60bfe62a0aaf0f037ff
BLAKE2b-256 checksum
How to use checksums
326e3fa7b6166196dd8b4cb972517c780d101871fdcb016b1ff59d07bb534feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp39-cp39-win32.whl
Size 21.3 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
484a23369cf461fdfa6d88d8c238e7129a469f7c961f257c8f5668536d9c2df9
BLAKE2b-256 checksum
How to use checksums
27fd698612d51487d3d9d4ed60b9712b0d11a64404581bbc1bfa89c800e957a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp38-cp38-win_amd64.whl
Size 23.8 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
fb29dd36c0d7fd66c6abefe7871aecbd1fda00cb38e972fad668a9558e531a12
BLAKE2b-256 checksum
How to use checksums
596f0b2563eb5020f6ad35f45e37b81c45ec65f3795a65562aa9d11ac0f8b5e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

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

Download URL winkerberos-0.9.1-cp38-cp38-win32.whl
Size 21.3 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
167d0c58741d5624518aa94694e079831a9b1de1b99b1f901330c18c785d00f7
BLAKE2b-256 checksum
How to use checksums
69f616cc64502d14c4228558cc0632cc53f0b541b50717a52cdb3e6585bfb728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp37-cp37m-win_amd64.whl

Download URL winkerberos-0.9.1-cp37-cp37m-win_amd64.whl
Size 23.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
773ba1ef924de8ad9c8c1dc24bfaa40e1182f9978e46d2dcb98856c4ab069ce4
BLAKE2b-256 checksum
How to use checksums
11ed3bc4dd65f069c92b6ed9310babf173750ababb806b7ec1a4ddb7ad07de7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp37-cp37m-win32.whl

Download URL winkerberos-0.9.1-cp37-cp37m-win32.whl
Size 21.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
024657b9861f057a90f10fcc94de2ac7bf1d2d84b7f51386f68f1d77c99f58c7
BLAKE2b-256 checksum
How to use checksums
b37b16d6749330110cff801cf4a0d099020316cb6f76deffcea7aa3bf663e695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp36-cp36m-win_amd64.whl

Download URL winkerberos-0.9.1-cp36-cp36m-win_amd64.whl
Size 25.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
bf3e4aab04673660a8731fab527c4a838cfdfa935deada6cef0df8f8e9a6cd4d
BLAKE2b-256 checksum
How to use checksums
7c8405c565f76af2cbfb74bbe253bb00f964fcf1828686b5e29d2c0060677610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp36-cp36m-win32.whl

Download URL winkerberos-0.9.1-cp36-cp36m-win32.whl
Size 22.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
45cf5084640888ad025a6f6f9e1fb313e03d626101c1bcca6e82214d7e9c5ee3
BLAKE2b-256 checksum
How to use checksums
a8f5131fe29d4783ce0b5b565d9b0d6a5b0d7a71f9603d0b35cff259641496ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp35-cp35m-win_amd64.whl

Download URL winkerberos-0.9.1-cp35-cp35m-win_amd64.whl
Size 25.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
630cb3a5789532e3adac03ab51bc2fc2288cae70d39259a6bdd409d2a3c8b936
BLAKE2b-256 checksum
How to use checksums
7b226695a69bc6575765b4edb3001545e3c9428c4856d11b139a8a8550a6973f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp35-cp35m-win32.whl

Download URL winkerberos-0.9.1-cp35-cp35m-win32.whl
Size 22.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
044b7358cd34de6ae34c76aa48a40607e6f63835ff319516662c1c65f84f2feb
BLAKE2b-256 checksum
How to use checksums
93b35820f06483bc1c88ffd712e4f5ee875593b695f57027b7ac8c8f760fa0e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / winkerberos-0.9.1-cp27-cp27m-win_amd64.whl

Download URL winkerberos-0.9.1-cp27-cp27m-win_amd64.whl
Size 22.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
53c5109e95b9cf0a80198ee6953d6263b0c8d254cc3815e9091cff4544ab4697
BLAKE2b-256 checksum
How to use checksums
e06afa453bb86d4512e03f2639ac78a6f4a1ab53ca32b35035c9eaf830f1cd07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/2.7.18

Release files / winkerberos-0.9.1-cp27-cp27m-win32.whl

Download URL winkerberos-0.9.1-cp27-cp27m-win32.whl
Size 20.1 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
aba3190d8c1f1bb876f398346ff7d7c2e173046a1653086dad638dc3b16cccdf
BLAKE2b-256 checksum
How to use checksums
974b0fc609068e4f94c53c8eceb00a5687ad79ef041a9e856af999afc0b48f98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/2.7.18
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