• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

kerberos.egg-info/H03-May-2022-139102

pysrc/H09-Jan-2021-462291

src/H09-Jan-2021-2,5902,036

MANIFEST.inH A D09-Jan-202185 43

PKG-INFOH A D09-Jan-20215.6 KiB139102

README.mdH A D07-Jan-20213.9 KiB12084

setup.cfgH A D09-Jan-202138 53

setup.pyH A D03-May-20223 KiB13970

README.md

1# PyKerberos Package
2
3This Python package is a high-level wrapper for Kerberos (GSSAPI)
4operations.  The goal is to avoid having to build a module that wraps
5the entire Kerberos.framework, and instead offer a limited set of
6functions that do what is needed for client/server Kerberos
7authentication based on <http://www.ietf.org/rfc/rfc4559.txt>.
8
9Much of the C-code here is adapted from Apache's mod_auth_kerb-5.0rc7.
10
11
12## Build
13
14In this directory, run:
15
16```
17python setup.py build
18```
19
20## Testing
21
22To run the tests in the tests folder, you must have a valid Kerberos setup on
23the test machine. You can use the script .travis.sh as quick and easy way to
24setup a Kerberos KDC and Apache web endpoint that can be used for the tests.
25Otherwise you can also run the following to run a self contained Docker
26container
27
28```
29docker run \
30-v $(pwd):/app \
31-w /app \
32-e PYENV=2.7.13 \
33-e KERBEROS_USERNAME=administrator \
34-e KERBEROS_PASSWORD=Password01 \
35-e KERBEROS_REALM=example.com \
36-e KERBEROS_PORT=80 \
37ubuntu:16.04 \
38/bin/bash .travis.sh
39```
40
41The docker command needs to be run in the same directory as this library and
42you can test it with different Python versions by changing the value of the
43PYENV environment value set in the command.
44
45Please have a look at testing_notes.md for more information.
46
47
48## IMPORTANT
49
50The checkPassword method provided by this library is meant only for testing purposes as it does
51not offer any protection against possible KDC spoofing. That method should not be used in any
52production code.
53
54
55## Channel Bindings
56
57You can use this library to authenticate with Channel Binding support. Channel
58Bindings are tags that identify the particular data channel being used with the
59authentication. You can use Channel bindings to offer more proof of a valid
60identity. Some services like Microsoft's Extended Protection can enforce
61Channel Binding support on authorisation and you can use this library to meet
62those requirements.
63
64More details on Channel Bindings as set through the GSSAPI can be found here
65<https://docs.oracle.com/cd/E19455-01/806-3814/overview-52/index.html>. Using
66TLS as a example this is how you would add Channel Binding support to your
67authentication mechanism. The following code snippet is based on RFC5929
68<https://tools.ietf.org/html/rfc5929> using the 'tls-server-endpoint-point'
69type.
70
71```
72import hashlib
73
74def get_channel_bindings_application_data(socket):
75    # This is a highly simplified example, there are other use cases
76    # where you might need to use different hash types or get a socket
77    # object somehow.
78    server_certificate = socket.getpeercert(True)
79    certificate_hash = hashlib.sha256(server_certificate).hexdigest().upper()
80    certificate_digest = base64.b16decode(certificate_hash)
81    application_data = b'tls-server-end-point:%s' % certificate_digest
82
83    return application_data
84
85def main():
86    # Code to setup a socket with the server
87    # A lot of code to setup the handshake and start the auth process
88    socket = getsocketsomehow()
89
90    # Connect to the host and start the auth process
91
92    # Build the channel bindings object
93    application_data = get_channel_bindings_application_data(socket)
94    channel_bindings = kerberos.channelBindings(application_data=application_data)
95
96    # More work to get responses from the server
97
98    result, context = kerberos.authGSSClientInit(kerb_spn, gssflags=gssflags, principal=principal)
99
100    # Pass through the channel_bindings object as created in the kerberos.channelBindings method
101    result = kerberos.authGSSClientStep(context, neg_resp_value, channel_bindings=channel_bindings)
102
103    # Repeat as necessary
104```
105
106## Python APIs
107
108See kerberos.py.
109
110
111## Copyright and License
112
113Copyright (c) 2006-2021 Apple Inc.  All rights reserved.
114
115This software is licensed under the Apache License, Version 2.0.  The
116Apache License is a well-established open source license, enabling
117collaborative open source software development.
118
119See the "LICENSE" file for the full text of the license terms.
120