Skip to main content

High level interface to SSPI for Kerberos client auth

Project description

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.4+.

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winkerberos-0.8.0.zip (44.3 kB view details)

Uploaded Source

Built Distributions

winkerberos-0.8.0-cp310-cp310-win_amd64.whl (24.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

winkerberos-0.8.0-cp310-cp310-win32.whl (21.3 kB view details)

Uploaded CPython 3.10 Windows x86

winkerberos-0.8.0-cp39-cp39-win_amd64.whl (25.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

winkerberos-0.8.0-cp39-cp39-win32.whl (21.6 kB view details)

Uploaded CPython 3.9 Windows x86

winkerberos-0.8.0-cp38-cp38-win_amd64.whl (25.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

winkerberos-0.8.0-cp38-cp38-win32.whl (21.6 kB view details)

Uploaded CPython 3.8 Windows x86

winkerberos-0.8.0-cp37-cp37m-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

winkerberos-0.8.0-cp37-cp37m-win32.whl (21.5 kB view details)

Uploaded CPython 3.7m Windows x86

winkerberos-0.8.0-cp36-cp36m-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

winkerberos-0.8.0-cp36-cp36m-win32.whl (21.5 kB view details)

Uploaded CPython 3.6m Windows x86

winkerberos-0.8.0-cp35-cp35m-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.5m Windows x86-64

winkerberos-0.8.0-cp35-cp35m-win32.whl (21.5 kB view details)

Uploaded CPython 3.5m Windows x86

winkerberos-0.8.0-cp34-cp34m-win_amd64.whl (21.8 kB view details)

Uploaded CPython 3.4m Windows x86-64

winkerberos-0.8.0-cp34-cp34m-win32.whl (20.0 kB view details)

Uploaded CPython 3.4m Windows x86

winkerberos-0.8.0-cp27-cp27m-win_amd64.whl (22.6 kB view details)

Uploaded CPython 2.7m Windows x86-64

winkerberos-0.8.0-cp27-cp27m-win32.whl (20.2 kB view details)

Uploaded CPython 2.7m Windows x86

File details

Details for the file winkerberos-0.8.0.zip.

File metadata

  • Download URL: winkerberos-0.8.0.zip
  • Upload date:
  • Size: 44.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0.zip
Algorithm Hash digest
SHA256 2af9776b27dfdfe0bfdce1960c81078302588067112c32c663dc3a01412e04da
MD5 11c07932ccf3aefff96be453eb25dde9
BLAKE2b-256 01b43ab3da52bfeb2ddad33b4c0e8283f7df837504439cea83743c920b0c2201

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for winkerberos-0.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c49e0e67e4b1f30b768752f42fc450aa0eeadb12abe6cc9601c72ba562113cb4
MD5 d191508985e66128e0cfed1434f0786a
BLAKE2b-256 25d766a58682d218a93ee655b35645627b804d3a7fa260b43e618836318dbdc3

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for winkerberos-0.8.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7c29bf8e5fb4a466fd745443f8362cffa367a79a416463e06d81cee545ed7249
MD5 2b41f28397d6a0305d77164a5070d60f
BLAKE2b-256 4e9faab7d7303619ed20ca6379005262080e03d3ecac7754215c2d6324b70bf4

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5686eb22f85eb4b4c1825f251bf42a36cb44b00e84dcd040a54ba1ee2718fd87
MD5 e0c61a5e3681c6e7b0ad838f38491cd5
BLAKE2b-256 65383872aafa4a5d49aa58d5c33a70c0041fd40a4fe55659086e82df3b9b6c2b

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 8546ae9ee7906dbad4bf66f8651b8e4fb20177f66c2796723304a23b52165c30
MD5 2fa76bf07221cb48a02f978108d0f95d
BLAKE2b-256 d8ddc726bbd5b2e37bad0a8d43e5e9d4f5c814017fce670ee467e79501cbebbe

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f77363b0f20d0c753404ef432156e283f24218c99411029d48c8d2fda5652998
MD5 f9a38755a7938fc338ded30311f7f936
BLAKE2b-256 5b0aa98d27ebd3798abcd5483aac596109f4a80ec31706fde28955d5266bc85f

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 4c05050cdd38a9c0ed56be7bdc92789da35ce0da1ee6c7489c4981d790665740
MD5 dce8df73eb5350597cc4bce51a821eb6
BLAKE2b-256 fd2cf89591f07c5df1e323743a524338403fd5c3d0d886291ecc4fe84e818664

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c72dfaa89bf493e4f340e19389b45dab680356c9586b5b2114d62b24a4cf9b31
MD5 11bc1a1000acad78ade9e2256270c82a
BLAKE2b-256 bf0fceccd009cfeecaa24a1262e9539bcd37a519050ed6a9616c5d51d2157fe9

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp37-cp37m-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c4ce21a6687459625574c70918d6da369925c16f8581cadf3112dd48f7efefc2
MD5 3bb98d642dedd347832a0fa17471d10c
BLAKE2b-256 5aece2bc2b03f9897347bba0ab2328d04452b8de5f35fc73f33a080395c83192

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4744447f9a2c372d5ab8d2e94e0527c760526cb9f0b60ce17686713542efa7ee
MD5 8edfb6488502adc51ceb13f6ac9d1c47
BLAKE2b-256 894825502ea02b7a1884b2a87b0cd6563226b227d5db1eb5f00cf4ed6863c49c

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp36-cp36m-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 d0e175dcb377b83851e4cb79b2f8e7bb4549b78a04805350ebf07a2948ac9280
MD5 e65c5302ee5a5a1288a5ecc06c3b6ec3
BLAKE2b-256 d59c256f9d2f01284ef98af86289ce6b384b0505b3fb7e1d144139766963da41

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 fa98b3c52ed18a8832577618a3a69ec6c5311da72bf2a4a06227965b7c60c95c
MD5 b09dd6a1341fcb24f03af53b18dddfb2
BLAKE2b-256 29dba474688b71196010a9b5e5455089f17afc72f2f98fc64111314f9486c564

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp35-cp35m-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 a8f1b76ee723df371d57ded8e75cdc0e273ddf2bf2747b94382cd5702133faf1
MD5 a858d516d43b20a5732fd8d5b5e328fd
BLAKE2b-256 c280a4694b7520808b54fafe1463dcc809ad011bd0986c0346ef00fd872bcdee

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp34-cp34m-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp34-cp34m-win_amd64.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: CPython 3.4m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 378b5be58554ded93cba042d601e3c8b5aa9f6e4e16d1916da5a236296deaad8
MD5 afc28385baf346be6257c4e6f60c9ebe
BLAKE2b-256 e791262a1de132fc22e846aef6e50db2785161f495e07a16a9141da719936ae9

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp34-cp34m-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp34-cp34m-win32.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: CPython 3.4m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 b6e79a9042d63ea4dbf94e558d587332aab0d74e5c81a659a121d827ad217832
MD5 dc5c180665323b7df0da61088a8ebb3c
BLAKE2b-256 aba2beb0ee31a5b130f564f2dd95b5659f18309ad856fb81b1e085ffb2d3c687

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 e0a368af62e2ce340ad7da3b94d07c7758f70cd7d251932ca0b203a59148abd8
MD5 e49c70bb2538ef801625b5bf7a6b2ae4
BLAKE2b-256 efe92bac7f5e8086d2892b076c6d091aff0b2ef9bf9b57151055800e2fd60235

See more details on using hashes here.

File details

Details for the file winkerberos-0.8.0-cp27-cp27m-win32.whl.

File metadata

  • Download URL: winkerberos-0.8.0-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for winkerberos-0.8.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 1f6fb78c7f1a38f9128cf01733109b500495778b573eceab214d5ee96fd80e0f
MD5 f8f50af954bd498700233ef22bacc1ff
BLAKE2b-256 ea20d84e124696e001aab69588ccfde0daac35f28911aa074732f7473e0dd720

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page