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.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)

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.9.1.zip (44.0 kB view details)

Uploaded Source

Built Distributions

winkerberos-0.9.1-cp311-cp311-win_amd64.whl (23.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

winkerberos-0.9.1-cp311-cp311-win32.whl (21.3 kB view details)

Uploaded CPython 3.11 Windows x86

winkerberos-0.9.1-cp310-cp310-win_amd64.whl (23.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 Windows x86

winkerberos-0.9.1-cp39-cp39-win_amd64.whl (23.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

winkerberos-0.9.1-cp39-cp39-win32.whl (21.3 kB view details)

Uploaded CPython 3.9 Windows x86

winkerberos-0.9.1-cp38-cp38-win_amd64.whl (23.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

winkerberos-0.9.1-cp38-cp38-win32.whl (21.3 kB view details)

Uploaded CPython 3.8 Windows x86

winkerberos-0.9.1-cp37-cp37m-win_amd64.whl (23.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

winkerberos-0.9.1-cp37-cp37m-win32.whl (21.3 kB view details)

Uploaded CPython 3.7m Windows x86

winkerberos-0.9.1-cp36-cp36m-win_amd64.whl (25.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

winkerberos-0.9.1-cp36-cp36m-win32.whl (22.0 kB view details)

Uploaded CPython 3.6m Windows x86

winkerberos-0.9.1-cp35-cp35m-win_amd64.whl (25.2 kB view details)

Uploaded CPython 3.5m Windows x86-64

winkerberos-0.9.1-cp35-cp35m-win32.whl (22.0 kB view details)

Uploaded CPython 3.5m Windows x86

winkerberos-0.9.1-cp27-cp27m-win_amd64.whl (22.5 kB view details)

Uploaded CPython 2.7m Windows x86-64

winkerberos-0.9.1-cp27-cp27m-win32.whl (20.1 kB view details)

Uploaded CPython 2.7m Windows x86

File details

Details for the file winkerberos-0.9.1.zip.

File metadata

  • Download URL: winkerberos-0.9.1.zip
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1.zip
Algorithm Hash digest
SHA256 02ec925c2aa4fe4f7656792a76e346d8fab13e12ced2732354a21958adfe92c6
MD5 87848f7e2e452dc7b41f18d286553fa3
BLAKE2b-256 aaceddd1aa02552c876df8efc4710ced6148c749df8276705f8e94f84fcb0561

See more details on using hashes here.

File details

Details for the file winkerberos-0.9.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 60e47a551db0431a2e98b46ef9d9b59a70df0c0c450af0172747da7083573122
MD5 ab72e488585145bf3d95350f8d073100
BLAKE2b-256 834cd8cb38ad905b112065363bbcd625a6edb2f35da9d529379caf264ea1db82

See more details on using hashes here.

File details

Details for the file winkerberos-0.9.1-cp311-cp311-win32.whl.

File metadata

  • Download URL: winkerberos-0.9.1-cp311-cp311-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 26716c91900f19c8990d6e77026e1b1686e5bdb22ac829c87781ff80eba4603d
MD5 3eab3f18603cf1331c2c9e881ec73d3b
BLAKE2b-256 b7b23381cd9c5c756d9da6d836429fbf7fb558d7db402d56abf9b52d7dfb04c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 59499e9682961ea784fa41b85af499b699f2ff5f3a07fde30a51ce33d509fa96
MD5 0ade01bea6fd9f49285dc6cff72f6208
BLAKE2b-256 c3ecaaf4ca160bdf5752d8edbe8978ba362e21fd7b4d93a40b6090822c1f9b19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp310-cp310-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 4565476111ec30a9def8f4c31bb937e165ab9862ad11ffa700f431f0d4941030
MD5 30427a02a35e4d8fd2ca71e935d56ae0
BLAKE2b-256 3063c49029c8afe6b6f94a9d51fda87d9be63bde7f233f7aa67db18b0146edbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9842854fa5527b72720e2911f1b6008736baacaf3df1a60bfe62a0aaf0f037ff
MD5 5361069e62c3dbec3a3801618c4d1164
BLAKE2b-256 326e3fa7b6166196dd8b4cb972517c780d101871fdcb016b1ff59d07bb534feb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp39-cp39-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 484a23369cf461fdfa6d88d8c238e7129a469f7c961f257c8f5668536d9c2df9
MD5 54e50e309ab920c7bdc22f6ba0b5a81e
BLAKE2b-256 27fd698612d51487d3d9d4ed60b9712b0d11a64404581bbc1bfa89c800e957a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fb29dd36c0d7fd66c6abefe7871aecbd1fda00cb38e972fad668a9558e531a12
MD5 c59fe274104111fc6b50173dca11a6b0
BLAKE2b-256 596f0b2563eb5020f6ad35f45e37b81c45ec65f3795a65562aa9d11ac0f8b5e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp38-cp38-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 167d0c58741d5624518aa94694e079831a9b1de1b99b1f901330c18c785d00f7
MD5 3a437b4908b68e3b81198b579bace12f
BLAKE2b-256 69f616cc64502d14c4228558cc0632cc53f0b541b50717a52cdb3e6585bfb728

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 773ba1ef924de8ad9c8c1dc24bfaa40e1182f9978e46d2dcb98856c4ab069ce4
MD5 33f6013fdb4f8bb55fdeec0b27184b72
BLAKE2b-256 11ed3bc4dd65f069c92b6ed9310babf173750ababb806b7ec1a4ddb7ad07de7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 024657b9861f057a90f10fcc94de2ac7bf1d2d84b7f51386f68f1d77c99f58c7
MD5 160da688064a4d6efc8914e20e91cfae
BLAKE2b-256 b37b16d6749330110cff801cf4a0d099020316cb6f76deffcea7aa3bf663e695

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bf3e4aab04673660a8731fab527c4a838cfdfa935deada6cef0df8f8e9a6cd4d
MD5 c9a9c51e59688630869771ece53b086a
BLAKE2b-256 7c8405c565f76af2cbfb74bbe253bb00f964fcf1828686b5e29d2c0060677610

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 45cf5084640888ad025a6f6f9e1fb313e03d626101c1bcca6e82214d7e9c5ee3
MD5 f5a206c7bab6a1af9e11ca5f4aa5ba1e
BLAKE2b-256 a8f5131fe29d4783ce0b5b565d9b0d6a5b0d7a71f9603d0b35cff259641496ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.9.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 630cb3a5789532e3adac03ab51bc2fc2288cae70d39259a6bdd409d2a3c8b936
MD5 fc4bece2d5b817206a33a969bbbe357b
BLAKE2b-256 7b226695a69bc6575765b4edb3001545e3c9428c4856d11b139a8a8550a6973f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for winkerberos-0.9.1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 044b7358cd34de6ae34c76aa48a40607e6f63835ff319516662c1c65f84f2feb
MD5 37eb65355f316018b3c36dd88562711d
BLAKE2b-256 93b35820f06483bc1c88ffd712e4f5ee875593b695f57027b7ac8c8f760fa0e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for winkerberos-0.9.1-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 53c5109e95b9cf0a80198ee6953d6263b0c8d254cc3815e9091cff4544ab4697
MD5 8479eb7b2721a6cf52a9d2fa607c975b
BLAKE2b-256 e06afa453bb86d4512e03f2639ac78a6f4a1ab53ca32b35035c9eaf830f1cd07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.9.1-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for winkerberos-0.9.1-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 aba3190d8c1f1bb876f398346ff7d7c2e173046a1653086dad638dc3b16cccdf
MD5 7fca65de7874333b63a3df2bce2dd99b
BLAKE2b-256 974b0fc609068e4f94c53c8eceb00a5687ad79ef041a9e856af999afc0b48f98

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