Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mail/fdm fdm: Add OAuth 2.0 support for IMAP



details:   https://anonhg.NetBSD.org/pkgsrc/rev/40b69ef74056
branches:  trunk
changeset: 437664:40b69ef74056
user:      leot <leot%pkgsrc.org@localhost>
date:      Sat Aug 29 13:43:54 2020 +0000

description:
fdm: Add OAuth 2.0 support for IMAP

Patch shared upstream via:

 <https://github.com/nicm/fdm/pull/84>

PKGREVISION++

diffstat:

 mail/fdm/Makefile                     |   4 +-
 mail/fdm/distinfo                     |  10 ++++-
 mail/fdm/patches/patch-MANUAL         |  27 ++++++++++++
 mail/fdm/patches/patch-deliver-imap.c |  19 ++++++++
 mail/fdm/patches/patch-deliver.h      |  19 ++++++++
 mail/fdm/patches/patch-fdm.conf.5     |  37 ++++++++++++++++
 mail/fdm/patches/patch-fetch.h        |  27 ++++++++++++
 mail/fdm/patches/patch-imap-common.c  |  74 +++++++++++++++++++++++++++++++++
 mail/fdm/patches/patch-lex.c          |  19 ++++++++
 mail/fdm/patches/patch-parse.y        |  78 +++++++++++++++++++++++++++++++++++
 10 files changed, 311 insertions(+), 3 deletions(-)

diffs (truncated from 366 to 300 lines):

diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/Makefile
--- a/mail/fdm/Makefile Sat Aug 29 13:18:03 2020 +0000
+++ b/mail/fdm/Makefile Sat Aug 29 13:43:54 2020 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.15 2020/01/18 21:49:49 jperkin Exp $
+# $NetBSD: Makefile,v 1.16 2020/08/29 13:43:54 leot Exp $
 
 DISTNAME=      fdm-2.0
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    mail
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=nicm/}
 
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/distinfo
--- a/mail/fdm/distinfo Sat Aug 29 13:18:03 2020 +0000
+++ b/mail/fdm/distinfo Sat Aug 29 13:43:54 2020 +0000
@@ -1,8 +1,16 @@
-$NetBSD: distinfo,v 1.13 2019/03/24 14:41:05 leot Exp $
+$NetBSD: distinfo,v 1.14 2020/08/29 13:43:54 leot Exp $
 
 SHA1 (fdm-2.0.tar.gz) = 4da70cca5791457489d9e0a018706a6696609eab
 RMD160 (fdm-2.0.tar.gz) = b07dc4ee0b8de3362177d74bd935d1ae4dad961d
 SHA512 (fdm-2.0.tar.gz) = 9c321dfd200af7b7d396524a43a3ac4b569cddda0a2096122b935e9d7bdb8101f269341fae5bbd4ad8a2947312774da2d49e03eddc67c6ecbce4e1ff9488ebe2
 Size (fdm-2.0.tar.gz) = 180662 bytes
+SHA1 (patch-MANUAL) = e7cc443a970b350be9ced14f73bb873023ab91e3
 SHA1 (patch-Makefile.am) = 2169ebc8e7c920cdf8492ee2039b410f5a6e358c
+SHA1 (patch-deliver-imap.c) = 3be95a6ef4ba8946a72e8bb4c0c4c32384044e3f
+SHA1 (patch-deliver.h) = 618d73f8fa2d69112ae85d858261d7f77a4e5c98
+SHA1 (patch-fdm.conf.5) = 4d43169edec6958ff591487be34f041054bfb476
+SHA1 (patch-fetch.h) = 225c3d83282057781cacd7ba84af1d16bd4b7616
+SHA1 (patch-imap-common.c) = e45a163e7ee4c8e386157babea8c43a7b26b77d1
+SHA1 (patch-lex.c) = 457abcef58add76cd4b76351a1961c45abc2f783
+SHA1 (patch-parse.y) = 56e27e155b6d99e3539d4dfe7f90d5c607fb4153
 SHA1 (patch-shm-mmap.c) = 3cd0c54c982ddd4702ad921ebf5f1b890b503cd4
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-MANUAL
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-MANUAL     Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,27 @@
+$NetBSD: patch-MANUAL,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- MANUAL.orig        2019-02-12 22:08:26.000000000 +0000
++++ MANUAL
+@@ -680,9 +680,12 @@ Examples of IMAP and IMAPS accounts incl
+ 
+ By default, fdm prefers the CRAM-MD5 authentication method, since no passwords
+ are sent in the clear.  If the server does not advertise CRAM-MD5 capability,
+-the older LOGIN method is used.  For IMAPS connections (which use SSL), the
+-LOGIN method is just as secure.  Either of these methods may be disabled with
+-the 'no-cram-md5' and 'no-login' options.
++and 'oauthbearer' option is not passed the older LOGIN method is used.  For
++IMAPS connections (which use SSL), the LOGIN method is just as secure.  
++Either of these methods may be disabled with the 'no-cram-md5' and 'no-login'
++options.  If the server advertises OAUTHBEARER capability, 'oauthbearer'
++option will use OAuth 2.0 bearer tokens - passed via 'pass' keyword - as
++authentication method.
+ 
+ The 'starttls' keyword may be added to an IMAP account to attemp STARTTLS after
+ connection.
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-deliver-imap.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-deliver-imap.c     Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,19 @@
+$NetBSD: patch-deliver-imap.c,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- deliver-imap.c.orig        2019-02-12 22:08:26.000000000 +0000
++++ deliver-imap.c
+@@ -197,6 +197,7 @@ deliver_imap_deliver(struct deliver_ctx 
+       fdata.pass = data->pass;
+       fdata.nocrammd5 = data->nocrammd5;
+       fdata.nologin = data->nologin;
++      fdata.oauthbearer = data->oauthbearer;
+       memcpy(&fdata.server, &data->server, sizeof fdata.server);
+       fdata.io = io;
+       fdata.only = FETCH_ONLY_ALL;
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-deliver.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-deliver.h  Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,19 @@
+$NetBSD: patch-deliver.h,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- deliver.h.orig     2019-02-12 22:08:26.000000000 +0000
++++ deliver.h
+@@ -82,6 +82,7 @@ struct deliver_imap_data {
+       struct server    server;
+       int              nocrammd5;
+       int              nologin;
++      int              oauthbearer;
+       int              starttls;
+ 
+       struct replstr   folder;
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-fdm.conf.5
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-fdm.conf.5 Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,37 @@
+$NetBSD: patch-fdm.conf.5,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- fdm.conf.5.orig    2019-02-12 22:08:26.000000000 +0000
++++ fdm.conf.5
+@@ -473,6 +473,7 @@ not be read from
+ .Op Ic no-login
+ .Op Ic starttls
+ .Op Ic insecure
++.Op Ic oauthbearer
+ .Xc
+ .It Xo Ic imap Ic server Ar host
+ .Op Ic port Ar port
+@@ -492,6 +493,7 @@ not be read from
+ .Op Ic no-cram-md5
+ .Op Ic no-login
+ .Op Ic insecure
++.Op Ic oauthbearer
+ .Xc
+ These define an IMAP or IMAPS account.
+ The parameters are as for a POP3 or POP3S account, aside from the additional
+@@ -530,6 +532,9 @@ after connection.
+ .Ic insecure
+ allows the use of insecure protocols, which currently includes SSLv2, SSLv3
+ and TLS1.0.
++.Pp
++.Ic oauthbearer
++attempts to use OAuth 2.0 bearer token as authentication method.
+ .It Xo Ic imap Ic pipe Ar command
+ .Op Ar userpass
+ .Op Ar folders
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-fetch.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-fetch.h    Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,27 @@
+$NetBSD: patch-fetch.h,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- fetch.h.orig       2019-02-12 22:08:26.000000000 +0000
++++ fetch.h
+@@ -204,6 +204,7 @@ struct fetch_imap_data {
+       int              starttls;
+       int              nocrammd5;
+       int              nologin;
++      int              oauthbearer;
+ 
+       u_int            folder;
+       struct strings  *folders;
+@@ -252,6 +253,7 @@ struct fetch_imap_mail {
+ #define IMAP_CAPA_STARTTLS 0x4
+ #define IMAP_CAPA_NOSPACE 0x8
+ #define IMAP_CAPA_GMEXT 0x10
++#define IMAP_CAPA_AUTH_OAUTHBEARER 0x20
+ 
+ /* fetch-maildir.c */
+ extern struct fetch    fetch_maildir;
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-imap-common.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-imap-common.c      Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,74 @@
+$NetBSD: patch-imap-common.c,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- imap-common.c.orig 2019-02-12 22:08:26.000000000 +0000
++++ imap-common.c
+@@ -45,6 +45,7 @@ int  imap_state_connect(struct account *,
+ int   imap_state_capability1(struct account *, struct fetch_ctx *);
+ int   imap_state_capability2(struct account *, struct fetch_ctx *);
+ int   imap_state_starttls(struct account *, struct fetch_ctx *);
++int   imap_state_oauthbearer_auth(struct account *, struct fetch_ctx *);
+ int   imap_state_cram_md5_auth(struct account *, struct fetch_ctx *);
+ int   imap_state_login(struct account *, struct fetch_ctx *);
+ int   imap_state_user(struct account *, struct fetch_ctx *);
+@@ -295,6 +296,12 @@ imap_pick_auth(struct account *a, struct
+ {
+       struct fetch_imap_data  *data = a->data;
+ 
++      /* Try OAUTHBEARER, if requested by user and if server supports it. */
++      if (data->oauthbearer && (data->capa & IMAP_CAPA_AUTH_OAUTHBEARER)) {
++              fctx->state = imap_state_oauthbearer_auth;
++              return (FETCH_AGAIN);
++      }
++
+       /* Try CRAM-MD5, if server supports it and user allows it. */
+       if (!data->nocrammd5 && (data->capa & IMAP_CAPA_AUTH_CRAM_MD5)) {
+               if (imap_putln(a,
+@@ -401,6 +408,9 @@ imap_state_capability1(struct account *a
+       if (strstr(line, "AUTH=CRAM-MD5") != NULL)
+               data->capa |= IMAP_CAPA_AUTH_CRAM_MD5;
+ 
++      if (strstr(line, "AUTH=OAUTHBEARER") != NULL)
++              data->capa |= IMAP_CAPA_AUTH_OAUTHBEARER;
++
+       /* Use XYZZY to detect Google brokenness. */
+       if (strstr(line, "XYZZY") != NULL)
+               data->capa |= IMAP_CAPA_XYZZY;
+@@ -470,6 +480,31 @@ imap_state_starttls(struct account *a, s
+       return (imap_pick_auth(a, fctx));
+ }
+ 
++/* OAUTHBEARER auth state. */
++int
++imap_state_oauthbearer_auth(struct account *a, struct fetch_ctx *fctx)
++{
++      struct fetch_imap_data  *data = a->data;
++      char                    *src, *b64;
++
++      xasprintf(&src,
++          "n,a=%s,\001host=%s\001port=%d\001auth=Bearer %s\001\001",
++          data->user, data->server.host, data->server.port, data->pass);
++      b64 = imap_base64_encode(src);
++      xfree(src);
++
++      if (imap_putln(a,
++          "%u AUTHENTICATE OAUTHBEARER %s", ++data->tag, b64) != 0) {
++              xfree(b64);
++              return (FETCH_ERROR);
++      }
++      xfree(b64);
++
++      fctx->state = imap_state_pass;
++      return (FETCH_BLOCK);
++}
++
++
+ /* CRAM-MD5 auth state. */
+ int
+ imap_state_cram_md5_auth(struct account *a, struct fetch_ctx *fctx)
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-lex.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-lex.c      Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,19 @@
+$NetBSD: patch-lex.c,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- lex.c.orig 2019-02-12 22:08:26.000000000 +0000
++++ lex.c
+@@ -157,6 +157,7 @@ static const struct token tokens[] = {
+       { "no-verify", TOKNOVERIFY },
+       { "none", TOKNONE },
+       { "not", TOKNOT },
++      { "oauthbearer", TOKOAUTHBEARER },
+       { "old-only", TOKOLDONLY },
+       { "or", TOKOR },
+       { "parallel-accounts", TOKPARALLELACCOUNTS },
diff -r e5892806afd6 -r 40b69ef74056 mail/fdm/patches/patch-parse.y
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/fdm/patches/patch-parse.y    Sat Aug 29 13:43:54 2020 +0000
@@ -0,0 +1,78 @@
+$NetBSD: patch-parse.y,v 1.1 2020/08/29 13:43:54 leot Exp $
+
+Add support for OAUTHBEARER (OAuth 2.0 bearer tokens, as documented by
+RFC 7628) for IMAP.
+
+Patch shared upstream via:
+
+ <https://github.com/nicm/fdm/pull/84>
+
+--- parse.y.orig       2019-02-12 22:08:26.000000000 +0000
++++ parse.y
+@@ -206,6 +206,7 @@ yyerror(const char *fmt, ...)



Home | Main Index | Thread Index | Old Index