Adding CRAM-MD5 server authentication #466
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #337 by adding support for CRAM-MD5 authentication.
I am unable to run the tests (they currently fail on master as well), but have tested this against my IMAP server which runs CRAM-MD5 authentication (debug log below to show it).
Would love some help figuring out how to provide a test suite for this as well.
Also I was unsure about how I'm sending the challenge response. I tried using
#_enqueuebut it was adding information to the start of the command; the challenge needs to be send with no leading information.I noticed this structure:
In
#_processQueuebut that uses the current request type to handle it's munging of the command. The challenge response has no type -- it's literally just the base64 encoded HMAC digest with the username pre-pended with a space, so I'm just writing directly to the socket and leavingthis._curReqalone (which seems to be the best case out of all the methods I tried.){"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"[connection] Connected to host","time":"2015-04-03T21:13:48.183Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= '* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=CRAM-MD5] Dovecot ready.'","time":"2015-04-03T21:13:48.261Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"=> 'A0 CAPABILITY'","time":"2015-04-03T21:13:48.262Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= '* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=CRAM-MD5'","time":"2015-04-03T21:13:48.341Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= 'A0 OK Pre-login capabilities listed, post-login capabilities have more.'","time":"2015-04-03T21:13:48.341Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"=> 'A1 AUTHENTICATE CRAM-MD5'","time":"2015-04-03T21:13:48.342Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= '+ PDIzNDc3NTc0MzQ1NDYwMTUuMTQyODA5NjAxMEBtYWlsLnNlbGZhc3NlbWJsZWQub3JnPg=='","time":"2015-04-03T21:13:48.421Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"=> [SECRET RESPONSE COMMENTED OUT]","time":"2015-04-03T21:13:48.421Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= '* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS'","time":"2015-04-03T21:13:48.504Z","v":0} {"name":"nodemailapp","hostname":"NewOSX","pid":36165,"level":60,"msg":"<= 'A1 OK Logged in'","time":"2015-04-03T21:13:48.504Z","v":0}