]> diplodocus.org Git - nmh/commit
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)
commit803f254122dc757db104a4c36cf98b726be004be
tree2eba2b658e7bf84017db53377fa47002af324e85
parent7f84f008c3927da991d81fc1a3add7cc07135830
Implement OAuth 2.0 [1] for XOAUTH2 in SMTP [2] and POP3 [3].

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.
32 files changed:
.gitignore
Makefile.am
config/version.sh
configure.ac
h/mh.h
h/oauth.h [new file with mode: 0644]
h/popsbr.h
h/prototypes.h
man/inc.man
man/mhlogin.man [new file with mode: 0644]
man/msgchk.man
man/send.man
mts/smtp/smtp.c
mts/smtp/smtp.h
sbr/error.c
sbr/oauth.c [new file with mode: 0644]
sbr/readconfig.c
test/fakehttp.c [new file with mode: 0644]
test/fakepop.c
test/fakesmtp.c
test/oauth/common.sh [new file with mode: 0644]
test/oauth/test-inc [new file with mode: 0755]
test/oauth/test-mhlogin [new file with mode: 0755]
test/oauth/test-send [new file with mode: 0755]
test/oauth/test-share [new file with mode: 0755]
test/server.c [new file with mode: 0644]
uip/inc.c
uip/mhlogin.c [new file with mode: 0644]
uip/msgchk.c
uip/popsbr.c
uip/post.c
uip/send.c