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.6, 2.7, and 3.3+.

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.7.0.zip (42.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

winkerberos-0.7.0-cp39-cp39-win_amd64.whl (23.3 kB view details)

Uploaded CPython 3.9Windows x86-64

winkerberos-0.7.0-cp39-cp39-win32.whl (20.6 kB view details)

Uploaded CPython 3.9Windows x86

winkerberos-0.7.0-cp38-cp38-win_amd64.whl (23.2 kB view details)

Uploaded CPython 3.8Windows x86-64

winkerberos-0.7.0-cp38-cp38-win32.whl (20.6 kB view details)

Uploaded CPython 3.8Windows x86

winkerberos-0.7.0-cp37-cp37m-win_amd64.whl (19.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

winkerberos-0.7.0-cp37-cp37m-win32.whl (16.3 kB view details)

Uploaded CPython 3.7mWindows x86

winkerberos-0.7.0-cp36-cp36m-win_amd64.whl (21.3 kB view details)

Uploaded CPython 3.6mWindows x86-64

winkerberos-0.7.0-cp36-cp36m-win32.whl (18.9 kB view details)

Uploaded CPython 3.6mWindows x86

winkerberos-0.7.0-cp35-cp35m-win_amd64.whl (21.3 kB view details)

Uploaded CPython 3.5mWindows x86-64

winkerberos-0.7.0-cp35-cp35m-win32.whl (18.9 kB view details)

Uploaded CPython 3.5mWindows x86

winkerberos-0.7.0-cp34-cp34m-win_amd64.whl (18.7 kB view details)

Uploaded CPython 3.4mWindows x86-64

winkerberos-0.7.0-cp34-cp34m-win32.whl (17.4 kB view details)

Uploaded CPython 3.4mWindows x86

winkerberos-0.7.0-cp33-cp33m-win_amd64.whl (18.7 kB view details)

Uploaded CPython 3.3mWindows x86-64

winkerberos-0.7.0-cp33-cp33m-win32.whl (17.4 kB view details)

Uploaded CPython 3.3mWindows x86

winkerberos-0.7.0-cp27-cp27m-win_amd64.whl (19.3 kB view details)

Uploaded CPython 2.7mWindows x86-64

winkerberos-0.7.0-cp27-cp27m-win32.whl (17.6 kB view details)

Uploaded CPython 2.7mWindows x86

winkerberos-0.7.0-cp26-cp26m-win_amd64.whl (19.6 kB view details)

Uploaded CPython 2.6mWindows x86-64

winkerberos-0.7.0-cp26-cp26m-win32.whl (17.9 kB view details)

Uploaded CPython 2.6mWindows x86

File details

Details for the file winkerberos-0.7.0.zip.

File metadata

  • Download URL: winkerberos-0.7.0.zip
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for winkerberos-0.7.0.zip
Algorithm Hash digest
SHA256 e304c28de838a48206edfe58b8deb5209a3fd8c6a755bd521c1ee6e656b06e27
MD5 c8618d802ea0cf28a8abdff1d96b27e7
BLAKE2b-256 85b2c5a66595bb477f1939596d80fa308e357c28abe22d3d6ce6cc2208c324ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for winkerberos-0.7.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f1da9ab07884c2f51b83d0fbf0802be897eed2de8339a7e6ad13f12b3ea087cb
MD5 9998db0fcee72e10325255c74c246fdf
BLAKE2b-256 1c674951cd20a2345425d37f450212843310e2288ec4325d3d16313df745fb34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for winkerberos-0.7.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 22161b0361552acd7b53e5d9145ef36283989aee67dd2cad7d2111908a13bb01
MD5 9f39689da1dc96fa522d49ea46f9354d
BLAKE2b-256 46e69b3b2e19f9029b7db72c70a2bd00416bbfb9e8f9075daba094861950106c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for winkerberos-0.7.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 893d97172e5260285a5f893c8814f15daa7376b004ef6b8de742569d4e2ff83f
MD5 1eba431985bb656e96db4678ac2449cb
BLAKE2b-256 64ed2ee72bdfb1fd369c64173a0498f4312a4f9d9699e8ca8c88349b83247150

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for winkerberos-0.7.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 f0c4309091a409d80d5e181ba726f10980671cd387daaabb239525262171d5ff
MD5 53ba6f5fca81c4c10e7f035e6794fb69
BLAKE2b-256 cacbeb105f9f455f6bc25eb04412b1c0e5b9b51be0714882a48044b0f15543c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for winkerberos-0.7.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0ca44087ab43979b0d8ffccb25353c8955d0bf755718405bcd2ad5e889eddfa8
MD5 872d213eca759c730743d284cb8fadf4
BLAKE2b-256 0f30ca51f0dc37a49f3ab0a2e1b3b38edeeab6faa3d40bc17b21e7a51a24ecde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winkerberos-0.7.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for winkerberos-0.7.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 14dbbcaeacc13aee0fc8a1d0bb12a29500642fe616c41b50bd9e0ff962372ec9
MD5 09bb7844d181231224083b295757161b
BLAKE2b-256 d43c6af9555e17e9c9fc0839a8a9ef74dfdd73df5f0768937a511ee7f3f9ffd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 240a1678c320501ade115511b4d10d44b9ff8e7d724b053dc5b3544cbfe6753b
MD5 b018ad91d6fd68e18129846d23f02d6f
BLAKE2b-256 c6278f2ce6016ed7cf3cae204164204d75b5d19da6623f75b0ffd61ac91a8a19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 712f29aec8a6d1bb87e8a05e9a65db3cfc6aa041334e2e3c0d5baebf9433471f
MD5 f9a68e61e5bda1f7e27e566209526829
BLAKE2b-256 c300230c35d7dcd5757240c0136972fc9a03db0d8eb4ab5c059abdf64a79c73c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 7c1bb92e0692ebd5b91bb2e11122f72c8da367c9524c0a25326cfd62833195a5
MD5 fff76dd396f68421502fb1a4e55d31a0
BLAKE2b-256 618eb2472bcfc6832b4d3c032f494be63c5baf6702da32a5bac201a472cec085

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 76d22b53fb7d6a9a46e4adce644f7be0023e4e05bcc1e9c27569d1bfe12df8bc
MD5 c601cb2bac0acda9cea296ce6ae78cd2
BLAKE2b-256 065506cf43529dc3936fcd027f5f8adc8225ed18348a090e5ed3eff1bd2fbeaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 494358695b1d05342af04149b531ed45bcfd9b351b05f67fc3a0dbb7b5ac3851
MD5 f9e6a96bb0cf9b847ce7899431c3d066
BLAKE2b-256 b17e192866b585a278bfebe6e39c4d715ecf6032de0e1620053715270d086588

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 d695f7990f8c04fec11dc64093d6107e42b67263a73653b6ad052d95403d6409
MD5 be3cde182161fc61dc4dc07033a351c2
BLAKE2b-256 a9a21d7cc2f3ed4ad890fe7ea3b9d10c5afe493bc737644aca77a7ad48ce9268

See more details on using hashes here.

File details

Details for the file winkerberos-0.7.0-cp33-cp33m-win_amd64.whl.

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 764728ce71f7150da664a9dd4398ecfdd1e44fdb50c5d9fdce719f93b8897de0
MD5 28d3912b0a233a256c4ddcc2f5bde64d
BLAKE2b-256 f68289aa337720b32f07444cdcbc8fd2ad5286e5719dca527bbb8e12a8e97db7

See more details on using hashes here.

File details

Details for the file winkerberos-0.7.0-cp33-cp33m-win32.whl.

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 47b0279b734b2f497ae20172a3d0ee6dc81be642df5a51fc0a88b695123f4061
MD5 a8317b22132106828a6d8220654b730a
BLAKE2b-256 1b0fd00d9a426c1e4f82f2b43b960f36ccf8325a303bc06d5fedc3916fd273ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 95af58f2d24a93598ef6d11341910621fd4170912c82b5e5d793f2cafa0daf1f
MD5 f5aad51d962df8d86dd081d652dc6b29
BLAKE2b-256 d854a41cca8a7bc4aa11c123e86a60e0ad1640ac9fa78fe830a614f9274dbe41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 3e6ad24331b6bd020e43e60357463a1a73d47c935b918255796fc617ba6fae8f
MD5 0ac9f2b7dcce5e03071553e3b4fa6b14
BLAKE2b-256 8994c48bbc5c8e313da543756ce3956b2bc4b64063b2fa63aed5242eaf209a41

See more details on using hashes here.

File details

Details for the file winkerberos-0.7.0-cp26-cp26m-win_amd64.whl.

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp26-cp26m-win_amd64.whl
Algorithm Hash digest
SHA256 c078ebfcfe65ce68cf59d00293ad5dd3e11b6d7fba4ee0f2cd333fa33ccea3c5
MD5 b04b3db124d6115bf20f6e966569838f
BLAKE2b-256 22f62f04d0551e2beec3c5486bc8d41b27d844c549edfb9510290ececd94781e

See more details on using hashes here.

File details

Details for the file winkerberos-0.7.0-cp26-cp26m-win32.whl.

File metadata

File hashes

Hashes for winkerberos-0.7.0-cp26-cp26m-win32.whl
Algorithm Hash digest
SHA256 541d9ba58d310a8f06f045e6e2d55d25462b26e1425cc997b6813c4e91c33b4c
MD5 1ce57a8b080c4771818732b7d4681173
BLAKE2b-256 b6d64f6393b3db2bd6673d68325635fcc821f6a1f99980a9649baef3cffd8689

See more details on using hashes here.

Supported by

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