| 1 |
pure-sasl |
| 2 |
========= |
| 3 |
|
| 4 |
.. image:: https://travis-ci.org/thobbs/pure-sasl.png?branch=master |
| 5 |
:target: https://travis-ci.org/thobbs/pure-sasl |
| 6 |
|
| 7 |
pure-sasl is a pure python client-side SASL implementation. |
| 8 |
|
| 9 |
At the moment, it supports the following mechanisms: ANONYMOUS, PLAIN, EXTERNAL, |
| 10 |
CRAM-MD5, DIGEST-MD5, and GSSAPI. Support for other mechanisms may be added in the |
| 11 |
future. Only GSSAPI supports a QOP higher than auth. Always use TLS! |
| 12 |
|
| 13 |
Both Python 2 and Python 3 are supported. |
| 14 |
|
| 15 |
Example Usage |
| 16 |
------------- |
| 17 |
|
| 18 |
.. code-block:: python |
| 19 |
|
| 20 |
from puresasl.client import SASLClient |
| 21 |
|
| 22 |
sasl = SASLClient('somehost2', 'customprotocol') |
| 23 |
conn = get_connection_to('somehost2') |
| 24 |
available_mechs = conn.get_mechanisms() |
| 25 |
sasl.choose_mechanism(available_mechs, allow_anonymous=False) |
| 26 |
while True: |
| 27 |
status, challenge = conn.get_challenge() |
| 28 |
if status == 'COMPLETE': |
| 29 |
break |
| 30 |
elif status == 'OK': |
| 31 |
response = sasl.process(challenge) |
| 32 |
conn.send_response(response) |
| 33 |
else: |
| 34 |
raise Exception(status) |
| 35 |
|
| 36 |
if not sasl.complete: |
| 37 |
raise Exception("SASL negotiation did not complete") |
| 38 |
|
| 39 |
# begin normal communication |
| 40 |
encoded = conn.fetch_data() |
| 41 |
decoded = sasl.unwrap(encoded) |
| 42 |
response = process_data(decoded) |
| 43 |
conn.send_data(sasl.wrap(response)) |
| 44 |
|
| 45 |
|
| 46 |
License |
| 47 |
------- |
| 48 |
Some of the mechanisms and utility functions are based on work done |
| 49 |
by David Alan Cridland and Lance Stout in Suelta: https://github.com/dwd/Suelta |
| 50 |
|
| 51 |
pure-sasl is open source under the |
| 52 |
`MIT license <http://www.opensource.org/licenses/mit-license.php>`_. |