]> diplodocus.org Git - nmh/commitdiff
Implement OAuth 2.0 [1] for XOAUTH2 in SMTP [2] and POP3 [3].
authorEric Gillespie <epg@google.com>
Tue, 9 Dec 2014 07:20:01 +0000 (23:20 -0800)
committerEric Gillespie <epg@google.com>
Tue, 9 Dec 2014 07:20:01 +0000 (23:20 -0800)
Google defined XOAUTH2 for SMTP, and that's what we use here.  If other
providers implement XOAUTH2 or some similar OAuth-based SMTP authentication
protocol, it should be simple to extend this.

[1] https://tools.ietf.org/html/rfc6749
[2] https://developers.google.com/gmail/xoauth2_protocol
[3] http://googleappsdeveloper.blogspot.com/2014/10/updates-on-authentication-for-gmail.html

Technically, XOAUTH2 is a SASL auth mechanism, but the implementation is so
trivial, I can't justify the code complexity or additional dependency
requirement of using Cyrus SASL for this.  So it's completely separate.

Changes:

- New dependencies:

  - jsmn (JSON processing library) bundled directly rather than linked to as
    an external library because there is no clear winner among JSON
    libraries for C and this one is tiny

  - libcurl is nearly ubiquitous and too heavy-weight to bundle, so link to
    the library the user must install separately

- Add oauth.h / oauth.c which do almost all the work, with quite a bit of
  help from curl and jsmn.

- Add new mhlogin program to authorize nmh to use the Gmail account and
  store the access and refresh tokens.

- Add new user_agent global to version.c (version.sh); not too happy with
  such a generic name, but the others had no mh_ prefix or anything...

- Add XOAUTH2 support to:
  mts/smtp/smtp.c uip/post.c uip/send.c uip/popsbr.c uip/inc.c uip/msgchk.c

- Split duplicated serving code out of fakepop.c and fakesmtp.c to new
  server.c and also use that for new fakehttp.c.

- Add XOAUTH2 support to fakepop.c and fakesmtp.c.


No differences found