classification
Title: Add support for AUTH command to poplib
Type: enhancement Stage: needs patch
Components: email, Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, dveeden, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2014-01-22 18:17 by dveeden, last changed 2014-01-23 13:55 by r.david.murray.

Files
File name Uploaded Description Edit
poplib_auth.patch dveeden, 2014-01-23 10:06 Initial patch review
Messages (4)
msg208837 - (view) Author: Daniël van Eeden (dveeden) Date: 2014-01-22 18:17
I use 'AUTH PLAIN <secret>' to login to a POP3 server with a proxy user. I can't use 'pass_()' as I need to supply a admin user and the user to proxy into.

class adminpopserver(poplib.POP3):
    def auth(self, method, secret):
        return self._shortcmd('AUTH %s %s' % (method, secret))

secret = "{user}\0{adminuser}\0{password}".format(
    user=user, 
    adminuser=adminuser, 
    password=password)
secret = secret.encode('base64').strip('\n')
msg208841 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-01-22 18:55
This is basically rfc 5034 support?  Sounds like a good idea.

I'm going to mark this issue as 'easy' because it isn't a whole lot of code, but for anyone who wants to tackle it, know that understanding the RFC and getting it *right* is not necessarily trivial, because: rfc :)
msg208904 - (view) Author: Daniël van Eeden (dveeden) Date: 2014-01-23 10:06
As far as I understood the RFC:

A client should send CAPA and check if there is a SASL tag in the response (e.g. "SASL PLAIN").

===============================
+OK Dovecot ready.
AUTH PLAIN base64_encoded_info
+OK Logged in.
LIST
===============================
I've replace the base64 encoded authentication info with 'base64_encoded_info'

For other authentication mechanisms the response can be longer (it may contain a challenge) and the request may only contain the mechanim.

I don't have a server which supports anything else than AUTH PLAIN, so I could verify/test this.
msg208923 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-01-23 13:55
imaplib has an API for handling that kind of thing.  Maybe we can model the poplib support off of that API.  It would be nice to be consistent, assuming it in fact makes sense for poplib as well.
History
Date User Action Args
2014-01-23 13:55:51r.david.murraysetmessages: + msg208923
2014-01-23 10:06:47dveedensetfiles: + poplib_auth.patch
keywords: + patch
messages: + msg208904
2014-01-22 18:55:55r.david.murraysettype: enhancement
components: + email
versions: + Python 3.5, - Python 2.7
keywords: + easy
nosy: + barry, r.david.murray

messages: + msg208841
stage: needs patch
2014-01-22 18:17:39dveedencreate