diff options
author | Julian Pidancet <julian.pidancet@oracle.com> | 2022-09-28 19:49:11 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-01 15:47:33 +0200 |
commit | 9217dbeea45830c1d1d3d8453b495b6792bc38ca (patch) | |
tree | 813f70196d1e34daa39e2261e598b0914d4dd880 /worker/imap/connect.go | |
parent | 45bff8851509432f6b5a21360ce67a7b2ca55eb5 (diff) | |
download | aerc-9217dbeea45830c1d1d3d8453b495b6792bc38ca.tar.gz |
imap,smtp: add XOAUTH2 support
Add XOAUTH2 authentication support for IMAP and SMTP. Although XOAUTH2
is now deprecated in favor of OAuthBearer, it is the only way to connect
to Office365 since Basic Auth is now completely removed.
Since XOAUTH2 is very similar to OAuthBearer and uses the same
configuration parameters, this is basically a copy-paste of the existing
OAuthBearer code.
However, XOAUTH2 support was removed from go-sasl library, so this
change reimports the code that was removed from go-sasl and offers it
a new home in lib/xoauth2.go. Hopefully it shouldn't be too hard to
maintain, being less than 50 SLOC.
Link: https://github.com/emersion/go-sasl/commit/7bfe0ed36a21
Implements: https://todo.sr.ht/~rjarry/aerc/78
Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/imap/connect.go')
-rw-r--r-- | worker/imap/connect.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/worker/imap/connect.go b/worker/imap/connect.go index 7c43b561..035feaba 100644 --- a/worker/imap/connect.go +++ b/worker/imap/connect.go @@ -80,6 +80,11 @@ func (w *IMAPWorker) connect() (*client.Client, error) { username, password, c); err != nil { return nil, err } + } else if w.config.xoauth2.Enabled { + if err := w.config.xoauth2.Authenticate( + username, password, c); err != nil { + return nil, err + } } else if err := c.Login(username, password); err != nil { return nil, err } |