From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Make `smtpmail-try-auth-method' a generic function. Date: Thu, 11 Jan 2018 15:42:23 +0100 Message-ID: <87shbch2y8.fsf@gmail.com> References: <87373c3olr.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1515681689 3976 195.159.176.226 (11 Jan 2018 14:41:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Jan 2018 14:41:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: emacs-devel To: Cesar Crusius Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 11 15:41:25 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZe2k-0000QX-9x for ged-emacs-devel@m.gmane.org; Thu, 11 Jan 2018 15:41:22 +0100 Original-Received: from localhost ([::1]:48036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZe4i-0006ys-1o for ged-emacs-devel@m.gmane.org; Thu, 11 Jan 2018 09:43:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZe3s-0006wA-SJ for emacs-devel@gnu.org; Thu, 11 Jan 2018 09:42:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZe3o-000247-Ub for emacs-devel@gnu.org; Thu, 11 Jan 2018 09:42:32 -0500 Original-Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZe3o-00022t-OW for emacs-devel@gnu.org; Thu, 11 Jan 2018 09:42:28 -0500 Original-Received: by mail-wr0-x242.google.com with SMTP id 100so2363356wrb.7 for ; Thu, 11 Jan 2018 06:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:user-agent:mime-version; bh=+5tSXMzU18Q79IdyztACz1lKwLxVoCP1WegiCyLlOck=; b=nkPaebBQfaVnFFZfx8M3JrGO0oCN9fGJUmnNA/liwLfLzluyYrvSlFmZNBcDGhx+X9 2fUWRwhhhBI8uthAAvoFqDfSn//NYDZZuw2QyLiwNk8IuuaUneycFqMDbnJRRdZAZ6ZB q5CTpE8+3YT2Mld0wo/CFflDBDxzjUeZvLQFp5QsCsIYCHdO9rWNPg+z/o+NxOvz9mDK pLha2tMXkWm8LbP+QZZRI/1/q0bAceKhe0BYd+TZeDoP0RI92VybKtuQfKKjcU+EUAbE TKQslaaNqXliaiQCFX3EJnQsehTftgzduEnDACUM99MWEEE20n7UL9GJBzGH9evyz4Ac r1Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:user-agent :mime-version; bh=+5tSXMzU18Q79IdyztACz1lKwLxVoCP1WegiCyLlOck=; b=o7zPxENcmzUZzEGBRMq7P+ztAUFk2lavOVqhlbOQOvoqcDqKI1sGVOkSBvXKBjZCJy gR1H7wa0tKDKDhJ7ih/FAxg6vNFJk2s578pLljFsJcSMHaZAq26PG1HR85hSfvu02Y63 nCQ3netyzXp/KjaBIccTdNaLmCUM5qQJHsZwnjIhtDYBZwrjJVUhMguzXvbZYlLDRn2n 1lk/nRdH7E+QdUJeVQ+2rwJhlv4e2ShyXwNyZMeeb6me+9s+1zxNfA2B11R2n05aAb/R drBwIiHg8w1kBdnyholoqnLjq/zJ27WDycMi3bOtwIXK+jd/f8RVHO4cHLgOGKSjU6bF wy4w== X-Gm-Message-State: AKGB3mI6wyNnlZpJGwJOFQWHb1UurvJOiYs3ZI7MYJK9bAXrz+JkvSoE 8sLY9QvII291ewzChnm1UpDlZMgO X-Google-Smtp-Source: ACJfBouHBdtJAPTtjedE7jCjc/forgcqwNVnyukxXaeWw9/j1v3SA36uynVAvCPqGp9Nv3yseZTT8Q== X-Received: by 10.223.158.76 with SMTP id v12mr15076939wre.223.1515681747072; Thu, 11 Jan 2018 06:42:27 -0800 (PST) Original-Received: from rpluim-ubuntu ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id b127sm786046wma.26.2018.01.11.06.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 06:42:25 -0800 (PST) Gmane-Reply-To-List: yes In-Reply-To: <87373c3olr.fsf@gmail.com> (Cesar Crusius's message of "Wed, 10 Jan 2018 22:18:24 -0800") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221834 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Cesar Crusius writes: > This allows for extra authentication mechanisms (such as XOAuth2) to > be added without having to advise any functions. > > * lisp/mail/smtpmail.el: Turn `smtpmail-try-auth-method' into a > generic function. > --- > lisp/mail/smtpmail.el | 33 +++++++++++++++++++++++++++++++-- > 1 file changed, 31 insertions(+), 2 deletions(-) > > diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el > index 20cbeb5f4e..46c1639832 100644 > --- a/lisp/mail/smtpmail.el > +++ b/lisp/mail/smtpmail.el > @@ -181,7 +181,25 @@ This is relative to `smtpmail-queue-dir'." >=20=20 > (defconst smtpmail-auth-supported '(cram-md5 plain login) > "List of supported SMTP AUTH mechanisms. > -The list is in preference order.") > +The list is in preference order. > + > +New mechanisms can be added by defining a method implementing the > +`smtpmail-try-auth-method' generic function for that mechanism, and > +then adding the mechanism to this list. As an example, the code below > +adds support for XOAuth2 authentication (assuming that there is an > +appropriate auth source extension that can provide the correct user > +and password): > + > +\(cl-defmethod smtpmail-try-auth-method > + (process (mech (eql xoauth2)) user password) > + (smtpmail-command-or-throw > + process > + (concat \"AUTH XOAUTH2 \" > + (base64-encode-string > + (concat \"user=3D\" user \"\\1auth=3DBearer \" password \"\\= 1\\1\") t)) > + 235)) > + > +\(add-to-list 'smtpmail-try-auth-method 'xoauth2)") ^^^^^^^^^^^^^^^^^^^^^^^^ This should say smtpmail-auth-supported, no? FWIW, I've tried your patch, and it doesn't break anything for me with gmail, although I haven't tried enabling XOAuth2 yet. Robert --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJaV3fPAAoJED165MeRD2FAn1AP/jYzGW272Dyx5bVaQ3CNCYdP oyfgmoUPuKC5mBvSMXwQzpZu5qaKTlmZh+iS6C391lD/jmh8Eh2yumEq9/c1EHbJ 4LjM1Brix+oOawFloiic/L1J2q49AlqmGDwmfW16IAh1qAVPU8gfjEyP97uyeRri vPbh9ZLm0Faj/T5Bbiyj4F2mT81D4oTLqwAFN2k7N9ggc9IgfF+tdSp2jkyrmOeC NBlIwnjPhanh0Gko2WYI9QRd3E0W568jSfaQdvylfJGMNwH04JVhqNT/Q64wsMx2 4BQY6pQQ7Mnm3pi4SJ7F3Unfpp2niOREBhBjUTAAIsjoieD3nVgLhsw9whDmoqse ug1I9nwyzzDZFWJCCVGWKoDeL3UQ4s3rLX9mbvwGUAlju3WonqqAwT27oJM5QQUQ kO9whuyIBAxZZ8tHam+mxEY1uJfNiL5+d5eK+HkJHC0l4RKbVDiMzL9PKIl2KSut WPaP25VRSBfR7pAvRLZLz0MDh5fvgAKMCRXBpZHq4B1A/8ySCqNEnPFPXsecRe8u xXvkYJHcMeRFKDcWvDo/AyHsonTQE8hdTmCPjXZZ4jloiRFYEMBbu2lwZn4SkQIq 7SbMqVCE7gu1mNNlD3hZEafN/aeSEASO+rmUoNssS1yRU2U7kOPnu0Pkn7lH8SZq G3RextP3LXxnITsR4oql =7ZLX -----END PGP SIGNATURE----- --=-=-=--