Hi, i&#39;ve faced the same problem and submitted a patch a few month ago, <br>your can check it here <a href="http://twistedmatrix.com/trac/ticket/4398">http://twistedmatrix.com/trac/ticket/4398</a> you&#39;ll find also a complet example attached.<br>
<br>My first problem was that, the way twisted pb authentication works we&#39;re supposed to have a plan version of passwords at server side.<br>Or this is not always the case, most application store a hashed version of the password, the hash method may be different from the one twisted pb use to pass the credential over the network<br>
and thus, we&#39;re not able to compare those values.<br><br>In my solution the user can define a custom hash method and tell twisted to use it, so that the password given by twisted over the network will be hashed the same way that the application does before storing it (in database for example), which means we can check if the password is correct without having a plain version of it.<br>
Not that, If we don&#39;t &quot;customize&quot; the hash method, the original twisted behaviour in used instead, and thus compatibility is preserved.<br><br>-- G<br><br><div class="gmail_quote">Message: 1<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Date: Thu, 26 Jul 2012 12:36:57 -0500<br>
From: Kevin Horn &lt;<a href="mailto:kevin.horn@gmail.com">kevin.horn@gmail.com</a>&gt;<br>
Subject: Re: [Twisted-Python] Password hash for Perspective Brokers<br>
To: Twisted general discussion &lt;<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>&gt;<br>
Message-ID:<br>
        &lt;CA+U=<a href="mailto:zK3W21_BAg9fbLZzsAmRJXReHsvGmRYb0JLT4sgVV78R7A@mail.gmail.com">zK3W21_BAg9fbLZzsAmRJXReHsvGmRYb0JLT4sgVV78R7A@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
On Thu, Jul 26, 2012 at 11:43 AM, &lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt; wrote:<br>
<br>
&gt; On 02:28 pm, <a href="mailto:spalax@gresille.org">spalax@gresille.org</a> wrote:<br>
&gt; &gt;         Hello<br>
&gt; &gt;         I have a problem with checkers in Twisted, which could be<br>
&gt; &gt;solved by<br>
&gt; &gt;adding a new feature. I think I can write the necessary code, but<br>
&gt; &gt;before<br>
&gt; &gt;doing so, I would like to hear you about it.<br>
&gt; &gt;<br>
&gt; &gt;# The problem<br>
&gt; &gt;<br>
&gt; &gt;         If I am right, the only way passwords can be hashed when using<br>
&gt; &gt;authentication with perspective brokers is using MD5 [1]. However,<br>
&gt; &gt;there<br>
&gt; &gt;are two flaws with it.<br>
&gt; &gt;<br>
&gt; &gt;* First, MD5 is no longer considered sure. It may be possible, from the<br>
&gt; &gt;hashed password, to find the original one.<br>
&gt; &gt;* Second, in the current implementation of Twisted, no salt is used to<br>
&gt; &gt;hash the password. A salt is considered good practise : it is harder to<br>
&gt; &gt;find the password from the hashed form, and two identical passwords<br>
&gt; &gt;have<br>
&gt; &gt;different hashed form, which prevent someone looking at the hashed<br>
&gt; &gt;passwords to see if two users have the same password.<br>
&gt;<br>
&gt; The second point is incorrect.  The hash is salted.  See the `respond`<br>
&gt; method in twisted/spread/pb.py.<br>
&gt; &gt;# A solution<br>
&gt; &gt;<br>
&gt; &gt;         I tried to implement the solution proposed in [1], and I think<br>
&gt; &gt;I can<br>
&gt; &gt;manage to do it. However, this seems to be a not-so-smart hack, which<br>
&gt; &gt;is<br>
&gt; &gt;not guaranteed to work in future releases of Twisted. That is why I am<br>
&gt; &gt;proposing a patch.<br>
&gt; &gt;<br>
&gt; &gt;         The patch would introduce some arguments to class<br>
&gt; &gt;PBServerFactory [2]<br>
&gt; &gt;to use (or not) a salt, and a different hash function. I am not settled<br>
&gt; &gt;down yet about the new signature of this class, but what is sure is<br>
&gt; &gt;that<br>
&gt; &gt;the default must be the actual behaviour, not to break programs already<br>
&gt; &gt;using Twisted. Then, I hesitate between<br>
&gt;<br>
&gt; A good approach would be to parameterize the supported authentication<br>
&gt; mechanisms in an extensible way, rather than just hard coding one or two<br>
&gt; new (probably better) options.<br>
&gt;<br>
&gt; In other words, a SASL implementation for PB would be the best way to<br>
&gt; go.<br>
&gt;<br>
&gt; The existing API and behavior should indeed be preserved as-is for<br>
&gt; backwards compatibility.  The new authentication features should be<br>
&gt; exposed under a new API - either as new optional arguments accepted by<br>
&gt; PBServerFactory (and perhaps PBClientFactory) and new login methods<br>
&gt; (again, probably on those two classes).<br>
&gt;<br>
&gt; Jean-Paul<br>
&gt;<br>
&gt;<br>
It would probably also help if someone finished the &quot;Generic SASL<br>
implementation&quot; ticket.<br>
<br>
Lessee, who was working on that last?<br>
<br>
Crap. It was me.<br>
<br>
Sorry about that.<br>
<br>
Kevin Horn<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://twistedmatrix.com/pipermail/twisted-python/attachments/20120726/191265a5/attachment-0001.htm" target="_blank">http://twistedmatrix.com/pipermail/twisted-python/attachments/20120726/191265a5/attachment-0001.htm</a><br>

<br>
------------------------------<br>
<br></blockquote></div>