Giter Club home page Giter Club logo

pure-sasl's Introduction

pure-sasl

https://travis-ci.org/thobbs/pure-sasl.png?branch=master

pure-sasl is a pure python client-side SASL implementation.

At the moment, it supports the following mechanisms: ANONYMOUS, PLAIN, EXTERNAL, CRAM-MD5, DIGEST-MD5, and GSSAPI. Support for other mechanisms may be added in the future. Only GSSAPI supports a QOP higher than auth. Always use TLS!

Both Python 2 and Python 3 are supported.

Example Usage

from puresasl.client import SASLClient

sasl = SASLClient('somehost2', 'customprotocol')
conn = get_connection_to('somehost2')
available_mechs = conn.get_mechanisms()
sasl.choose_mechanism(available_mechs, allow_anonymous=False)
while True:
    status, challenge = conn.get_challenge()
    if status == 'COMPLETE':
        break
    elif status == 'OK':
        response = sasl.process(challenge)
        conn.send_response(response)
    else:
        raise Exception(status)

if not sasl.complete:
    raise Exception("SASL negotiation did not complete")

# begin normal communication
encoded = conn.fetch_data()
decoded = sasl.unwrap(encoded)
response = process_data(decoded)
conn.send_data(sasl.wrap(response))

License

Some of the mechanisms and utility functions are based on work done by David Alan Cridland and Lance Stout in Suelta: https://github.com/dwd/Suelta

pure-sasl is open source under the MIT license.

pure-sasl's People

Contributors

aboudreault avatar aholmberg avatar beltran avatar ceache avatar elafontaine avatar iynehz avatar katriana avatar mike-tr-adamson avatar myyc avatar normal-cock avatar redbo avatar seocam avatar shizmob avatar thobbs avatar xavierba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pure-sasl's Issues

DIGEST-MD5 does not work with qop='auth-conf'

If qop='auth-conf', the client must accept one of the server's cipher algorithms. Currently, it does not send back a cipher, so the server sends back an error message and closes the connection.

I tried hardcoding cipher='3des', but I ran into errors encoding/decoding messages and did not know how to proceed from there.

I noticed that there is a comment that DIGEST-MD5 is "incomplete and untested". Can you please complete this module?

Support for python 3.4

Hi,

I'm trying out I get the following error:

File "/opt/pyvirtualenv/py_3.4_dj_1.9/lib/python3.4/site-packages/puresasl/client.py", line 15, in wrapped
return f(self, args, *kwargs)
File "/opt/pyvirtualenv/py_3.4_dj_1.9/lib/python3.4/site-packages/puresasl/client.py", line 141, in process
return self._chosen_mech.process(challenge)
File "/opt/pyvirtualenv/py_3.4_dj_1.9/lib/python3.4/site-packages/puresasl/mechanisms.py", line 407, in process
setattr(self, key, challenge_dict[key])
TypeError: attribute name must be string, not 'bytes'

TypeError: argument 2 must be str, not bytes

Python 3.5 (conda environment), pure-sasl 0.4.0 on RHEL 6.6.

Traceback (most recent call last):
  File "/data/data01/dev/edl/infra/mstr/landing/envs/ml_recommender/lib/python3.5/site-packages/impala/sasl_compat.py", line 8, in error_catcher
    yield
  File "/data/data01/dev/edl/infra/mstr/landing/envs/ml_recommender/lib/python3.5/site-packages/impala/sasl_compat.py", line 30, in encode
    return True, self.unwrap(incoming)
  File "/data/data01/dev/edl/infra/mstr/landing/envs/ml_recommender/lib/python3.5/site-packages/puresasl/client.py", line 15, in wrapped
    return f(self, *args, **kwargs)
  File "/data/data01/dev/edl/infra/mstr/landing/envs/ml_recommender/lib/python3.5/site-packages/puresasl/client.py", line 157, in unwrap
    return self._chosen_mech.unwrap(incoming)
  File "/data/data01/dev/edl/infra/mstr/landing/envs/ml_recommender/lib/python3.5/site-packages/puresasl/mechanisms.py", line 515, in unwrap
    kerberos.authGSSClientUnwrap(self.context, incoming)
TypeError: argument 2 must be str, not bytes

Using sasl (Cyrus-SASL bindings) instead of pure-sasl, impyla is able to connect.

SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports

Dear thobbs,

In first, I wish you a Happy New Year!

Can you add supports of:

  • SCRAM-SHA-1
  • SCRAM-SHA-1-PLUS
  • SCRAM-SHA-256
  • SCRAM-SHA-256-PLUS
  • SCRAM-SHA-512
  • SCRAM-SHA-512-PLUS
  • SCRAM-SHA3-512
  • SCRAM-SHA3-512-PLUS

You can add too:

  • SCRAM-SHA-224
  • SCRAM-SHA-224-PLUS
  • SCRAM-SHA-384
  • SCRAM-SHA-384-PLUS

"When using the SASL SCRAM mechanism, the SCRAM-SHA-256-PLUS variant SHOULD be preferred over the SCRAM-SHA-256 variant, and SHA-256 variants [RFC7677] SHOULD be preferred over SHA-1 variants [RFC5802]".

https://xmpp.org/extensions/inbox/hash-recommendations.html

-PLUS variants:

IMAP:

LDAP:

  • RFC5803: Lightweight Directory Access Protocol (LDAP) Schema for Storing Salted: Challenge Response Authentication Mechanism (SCRAM) Secrets: https://tools.ietf.org/html/rfc5803

HTTP:

2FA:

IANA:

Linked to:

GSSAPI wrap/unwrap functions should honor max_buffer

If I call client.wrap(HUGE_BUFFER) or client.unwrap(HUGE_BUFFER), where HUGE_BUFFER > max_buffer, it should raise an exception. The caller should probably call wrap() or unwrap() in a loop based on client._chosen_mech.max_buffer.

Feature Request: Server Mode

Is it difficult to add support for SASL on the server side? It is close AFAIK.

I'd like to have it for HTTP SASL, which is an Internet Draft we're working on. We're already doing it for Java and Apache modules, but I'd like to also demo WSGI middleware using it.

(I know I'm welcome to submit a PR. Frankly, for me this would be one level too deep to get into. So I hope this is a fair request to a project that already has most of the expertise.)

DIGEST-MD5 and auth-conf

Hi!

I am currently working on snakebite-py3, a Hadoop HDFS client written in Python. The software is currently maintained by Internet Archive: https://github.com/internetarchive/snakebite-py3

I sent a pull request a while ago to allow kerberos authentication and encryption with GSS-API using puresasl, since python-sasl (a wrapper around cyrus sasl) seemed not working and nobody really committed any code in ages to the repository. The code works great, I love this library :)

I am now trying to add the final block of code, that requires DIGEST-MD5 and auth-conf. It seems that this is not supported anymore by this library, but I'd love to know if it was possible to add it. I don't have any experience with SASL but I can offer help in case needed (code, tests, etc..).

Why would somebody need DIGEST-MD5 + auth-conf instead of using AES or similar? In Hadoop's case, this jira explains it really well: https://issues.apache.org/jira/browse/HDFS-6606

Basically I'd need DIGEST-MD5 encryption only to exchange keys and move to AES, a sort of extra crypto handshake.

I realize that this request seems a bit strange, but I am trying anyway, it seems to be a good use case and a lot of people would benefit from it.

Thanks in advance!

GSSAPI does not work on windows

There is no kerberos support when trying to use this on windows. I have a local fix enabling winkerberos i would like to contribute.

winkerberos incorrect capitalization of 'N' has been fixed

It is doing some magic, the winkerberos library has different capitalisation on the 'N' in name. this just makes it compatible.

Originally posted by @ryan-pip in #30 (comment)

This capitalization issue in winkerberos has been fixed. This line needs to be removed as currently it produces the following error:
AttributeError: module 'winkerberos' has no attribute 'authGSSClientUsername'

Using:
winkerberos=0.8.0
pure-sasl=0.6.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.