Okay, cool. I definitely agree that IUsernamePassword.checkPassword is dumb and support deprecating it.<span></span><br><br>On Monday, April 1, 2013, Shell  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It actually might be the appropriate thing already. There&#39;s a couple<br>
of possible reasons for renaming; one is that the password might not<br>
be hashed but the credentials object wants to insert additional logic<br>
(exarkun&#39;s statement in IRC) anyway, but technically that&#39;s just<br>
hashing using the identity function, so it should be OK.<br>
<br>
The other is that the credentials object might want to collect the<br>
plaintext password, and perform some logic based on that *before*<br>
collecting something which can be compared to something derived from<br>
the plaintext password from the other end of a protocol. I don&#39;t know<br>
of any protocols which do this off the top of my head, but I have a<br>
suspicion that at least a couple exist, and they&#39;d fit perfectly into<br>
this interface. If none do, then keeping it with the same name sounds<br>
fine to me.<br>
<br>
Cameron<br>
<br>
On 1 April 2013 22:12, Laurens Van Houtven &lt;_@lvh.cc&gt; wrote:<br>
&gt; Why does IUsernameHashedPassword have to be renamed? It sounds like it&#39;s the<br>
&gt; appropriate thing already.<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Apr 1, 2013 at 10:55 PM, Shell &lt;<a>cam.turn@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; The twisted.cred.IUsernamePassword interface declares:<br>
&gt;&gt;<br>
&gt;&gt; * IUsernamePassword.username - &quot;The username associated with these<br>
&gt;&gt; credentials.&quot;<br>
&gt;&gt; * IUsernamePassword.password - &quot;The password associated with these<br>
&gt;&gt; credentials.&quot;<br>
&gt;&gt; * IUsernamePassword.checkPassword(password) - &quot;Validate these<br>
&gt;&gt; credentials against the correct password.&quot;<br>
&gt;&gt;<br>
&gt;&gt; The issue is that the interface (according to exarkun) allows you to<br>
&gt;&gt; implement checkPassword() to do things other than the obvious<br>
&gt;&gt; &quot;password == self.password&quot;. Now, this is an issue because Twisted<br>
&gt;&gt; then explicitly supports (again, according to exarkun) two different<br>
&gt;&gt; uses of this interface by the credentials checker:<br>
&gt;&gt;<br>
&gt;&gt; * Call the checkPassword() method, passing it the correct password<br>
&gt;&gt; * Just take the password out and do whatever you want with it (which<br>
&gt;&gt; is necessary in any secure system)<br>
&gt;&gt;<br>
&gt;&gt; Now, imagine I write a version of checkPassword() in a library which<br>
&gt;&gt; does something security-centric (what would this be? shouldn&#39;t it be<br>
&gt;&gt; part of the checker?), assuming that it&#39;ll be used by a credentials<br>
&gt;&gt; checker which calls checkPassword(). Except... then, a library user<br>
&gt;&gt; uses it with a credentials checker which checks the password itself.<br>
&gt;&gt; Now they&#39;re skipping over my security-centric code!<br>
&gt;&gt;<br>
&gt;&gt; So I have to tell my library users that they have to use my library<br>
&gt;&gt; with a credentials checker which makes sure to call checkPassword(),<br>
&gt;&gt; not just one which accepts the correct interface.<br>
&gt;&gt;<br>
&gt;&gt; IUsernamePassword&#39;s docstring claims that the stored password must be<br>
&gt;&gt; reversible to plaintext to be compared with the password, which<br>
&gt;&gt; implies that taking the password out and doing other things is<br>
&gt;&gt; incorrect, unlike what exarkun suggests. In this case, exposing<br>
&gt;&gt; password in the interface makes little sense. In addition,<br>
&gt;&gt; twisted.cred.checkers.FilePasswordDB apparently ignores this docstring<br>
&gt;&gt; entirely already<br>
&gt;&gt;<br>
&gt;&gt; (<a href="http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.3.0/twisted/cred/checkers.py#L238" target="_blank">http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.3.0/twisted/cred/checkers.py#L238</a>).<br>

&gt;&gt;<br>
&gt;&gt; I propose that IUsernamePassword should be split into at least two<br>
&gt;&gt; interfaces:<br>
&gt;&gt;<br>
&gt;&gt; * IUsernamePassword, with only username and password, no methods,<br>
&gt;&gt; which allows password to be used in any way<br>
&gt;&gt; * Another interface, which only defines username and checkPassword() -<br>
&gt;&gt; possibly just a rename of IUsernameHashedPassword, which declares a<br>
&gt;&gt; similar interface<br>
&gt;&gt;<br>
&gt;&gt; However, this has the issue that any credential checker which can use<br>
&gt;&gt; the second interface would also be able to use an IUsernamePassword<br>
&gt;&gt; here if there were an adapter between the two, but support for this<br>
&gt;&gt; would have to go into every credential checker which supports the<br>
&gt;&gt; second interface at present. Maybe the Portal could automatically<br>
&gt;&gt; search for adapters if it can&#39;t find a direct match?<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Cameron<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Twisted-Python mailing list<br>
&gt;&gt; <a>Twisted-Python@twistedmatrix.com</a><br>
&gt;&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; cheers<br>
&gt; lvh<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Twisted-Python mailing list<br>
&gt; <a>Twisted-Python@twistedmatrix.com</a><br>
&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br></blockquote><br><br>-- <br>Sent from Gmail Mobile<br>