aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorF. Jason Park2022-11-30 23:10:58 -0800
committerF. Jason Park2022-12-14 06:40:55 -0800
commit9ac80e8a6e4969cfe88d5233dc4152bbfa46c848 (patch)
treecd44b91bd46448e66e66c9cbbed0dc07cb58c2d6 /doc/misc
parent2d96a18cd09be1c53b1242be1e0671cfc5b7fa8c (diff)
downloademacs-9ac80e8a6e4969cfe88d5233dc4152bbfa46c848.tar.gz
emacs-9ac80e8a6e4969cfe88d5233dc4152bbfa46c848.zip
Add dedicated auth-source section in ERC manual
* doc/misc/erc.texi: Move auth-source description from the Password subheading of the Advanced chapter's Connecting section to the new Integrations section as a new node, Auth-Source, and give it a bit more structure. Fix various misuses of xref vs. pxref. Convert URL subheading to subsection and add anchor. Prefer "backend" as a single word, based on usage in other manuals. Also replace loud "warning" in SASL troubleshooting section. * etc/ERC-NEWS: Re-link auth-source mention. * lisp/erc/erc-sasl.el (erc-sasl-auth-source-function): Update info node in doc string. * lisp/erc/erc-services.el (erc-auth-source-services-function): Re-link auth-source info node in doc string. * lisp/erc/erc.el (erc-password, erc-auth-source-server-function, erc-auth-source-join-function): Re-link auth-source info node in doc strings.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/erc.texi344
1 files changed, 219 insertions, 125 deletions
diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index 5ad739a77e1..2ab2e908940 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -570,10 +570,20 @@ toggle never mutates @code{erc-modules}.
570 570
571@menu 571@menu
572* Connecting:: Ways of connecting to an IRC server. 572* Connecting:: Ways of connecting to an IRC server.
573* SASL:: Authenticating via SASL 573* SASL:: Authenticating via SASL.
574* Sample Configuration:: An example configuration file. 574* Sample Configuration:: An example configuration file.
575* Integrations:: Integrations available for ERC. 575* Integrations:: Integrations available for ERC.
576* Options:: Options that are available for ERC. 576* Options:: Options that are available for ERC.
577
578@detailmenu
579--- Detailed Node Listing ---
580
581Integrations
582
583* URL:: Opening IRC URLs in ERC.
584* auth-source:: Retrieving auth-source entries with ERC.
585
586@end detailmenu
577@end menu 587@end menu
578 588
579@node Connecting 589@node Connecting
@@ -643,7 +653,7 @@ while helpers, like @code{erc-compute-nick}, will determine other
643parameters, and some, like @code{client-certificate}, will just be 653parameters, and some, like @code{client-certificate}, will just be
644@code{nil}. 654@code{nil}.
645 655
646@anchor{ERC client-certificate} 656@anchor{client-certificate}
647To use a certificate with @code{erc-tls}, specify the optional 657To use a certificate with @code{erc-tls}, specify the optional
648@var{client-certificate} keyword argument, whose value should be as 658@var{client-certificate} keyword argument, whose value should be as
649described in the documentation of @code{open-network-stream}: if 659described in the documentation of @code{open-network-stream}: if
@@ -687,6 +697,8 @@ machine irc.libera.chat key /home/bandali/my-cert.key cert /home/bandali/my-cert
687 697
688@xref{Help for users,,,auth, Emacs auth-source Library}, for more on the 698@xref{Help for users,,,auth, Emacs auth-source Library}, for more on the
689@file{.authinfo}/@file{.netrc} backend of @code{auth-source}. 699@file{.authinfo}/@file{.netrc} backend of @code{auth-source}.
700For other uses of auth-source throughout ERC, @pxref{auth-source,
701ERC's auth-source integration}.
690@end defun 702@end defun
691 703
692@subheading Server 704@subheading Server
@@ -778,9 +790,9 @@ ERC should automatically attempt to connect with another nickname.
778You can manually set another nickname with the /NICK command. 790You can manually set another nickname with the /NICK command.
779@end defopt 791@end defopt
780 792
781@anchor{ERC username} 793@anchor{username parameter}
782@subheading User 794@subheading User
783@cindex user 795@cindex username parameter
784 796
785@defun erc-compute-user &optional user 797@defun erc-compute-user &optional user
786Determine a suitable value to send as the first argument of the 798Determine a suitable value to send as the first argument of the
@@ -803,8 +815,27 @@ A permanent username value to send for all connections. It should be
803a string abiding by the rules of the network. 815a string abiding by the rules of the network.
804@end defopt 816@end defopt
805 817
818@anchor{password parameter}
819@anchor{server password}
820@cindex password, server
806@subheading Password 821@subheading Password
807@cindex password 822
823This parameter was traditionally meant to specify a @dfn{server
824password} to be sent along with the IRC @samp{PASS} command. However,
825such passwords aren't widely used. Instead, networks typically expect
826them, when present, to convey other authentication information. In
827the case of account-services (a.k.a., ``NickServ'') credentials, this
828typically involves a special syntax, such as @samp{myuser:mypass}.
829IRC bouncers often do something similar but include a pre-configured
830network-ID component, for example, @samp{bncuser/mynet:bncpass}.
831
832In general, if you have @emph{not} been asked by your network or
833bouncer to specify a repurposed server password, you should instead
834consider setting up @samp{services} or, preferably, @samp{sasl}, both
835ERC modules (@pxref{Modules}). In addition to performing
836network-account authentication, these obviate the need for this
837parameter completely, although both can optionally borrow it for their
838own purposes. (@xref{SASL, SASL in ERC}.)
808 839
809@defopt erc-prompt-for-password 840@defopt erc-prompt-for-password
810If non-@code{nil} (the default), @kbd{M-x erc} and @kbd{M-x erc-tls} 841If non-@code{nil} (the default), @kbd{M-x erc} and @kbd{M-x erc-tls}
@@ -814,109 +845,9 @@ invocations of @code{erc} and @code{erc-tls}.
814 845
815@noindent 846@noindent
816If you prefer, you can set this option to @code{nil} and use the 847If you prefer, you can set this option to @code{nil} and use the
817@code{auth-source} mechanism to store your password. For instance, if 848auth-source facility to retrieve a server password, although hitting
818the option @code{auth-sources} contains @file{~/.authinfo}, put 849@kbd{RET} at the prompt may achieve the same effect.
819something like the following in that file: 850@xref{auth-source, ERC's auth-source integration}, for more.
820
821@example
822machine irc.example.net login mynick password sEcReT
823@end example
824
825@noindent
826For server passwords, that is, passwords sent for the IRC @samp{PASS}
827command, the @samp{host} field (@w{@code{machine irc.example.net}} in
828the above example)
829corresponds to the @var{server} parameter used by @code{erc} and
830@code{erc-tls}. Unfortunately, specifying a network, like
831@samp{Libera.Chat}, or a specific network server, like
832@samp{platinum.libera.chat}, won't normally work for looking up a server
833password because such information isn't available during opening
834introductions. (Actually, ERC @emph{can} find entries with arbitrary
835@samp{host} values for any context, including server passwords, but
836that requires customizing the more advanced options below.)
837
838If ERC can't find a suitable server password, it will just skip the IRC
839@samp{PASS} command altogether, something users may want when using
840CertFP or engaging NickServ via ERC's ``services'' module. If that is
841what you'd like to do, you can also customize the option
842@code{erc-auth-source-server-function} to @code{nil} to skip
843server-password lookup for all servers. Note that some networks and
844IRCds may accept account-services authentication via server password
845using the nonstandard @samp{mynick:sEcReT} convention.
846
847As just mentioned, you can also use @code{auth-source} to authenticate
848to account services the traditional way, through a bot called
849@samp{NickServ}. To tell ERC to do that, set
850@code{erc-use-auth-source-for-nickserv-password} to @code{t}. For
851these and most other queries, entries featuring custom identifiers and
852networks are matched first, followed by network-specific servers and
853dialed endpoints (typically, the @var{server} argument passed to
854@code{erc}). The following netrc-style entries appear in order of
855precedence:
856
857@example
858machine Libera/cellphone login MyNick password sEcReT
859machine Libera.Chat login MyNick password sEcReT
860machine zirconium.libera.chat login MyNick password sEcReT
861machine irc.libera.chat login MyNick password sEcReT
862@end example
863
864@noindent
865Remember that field labels vary per backend, so @samp{machine} (in
866netrc's case) maps to auth-source's generalized notion of a host,
867hence the @samp{:host} keyword property. Also, be sure to mind the
868syntax of your chosen backend medium. For example, always quote
869channel names in a netrc file.
870
871If this all seems overly nuanced or just plain doesn't appeal to you,
872see options @code{erc-auth-source-services-function} and friends, described
873below. These let you query auth-source your way. Most users can
874simply ignore the passed-in arguments and get by with something like
875the following:
876
877@lisp
878(defun my-fancy-auth-source-func (&rest _)
879 (let* ((host (read-string "host: " nil nil "default"))
880 (pass (auth-source-pick-first-password :host host)))
881 (if (and pass (string-search "libera" host))
882 (concat "MyNick:" pass)
883 pass)))
884@end lisp
885
886Lastly, ERC also consults @code{auth-source} to find ``keys'' that may
887be required by certain channels you join. When modifying a
888traditional @code{auth-source} entry for this purpose, put the channel
889name in the @samp{user} field (for example, @samp{login "#fsf"}, in
890netrc's case). The actual key goes in the @samp{password} (or
891@samp{secret}) field.
892
893@noindent
894For details, @pxref{Top,,auth-source, auth, Emacs auth-source Library}.
895
896@anchor{ERC auth-source functions}
897@defopt erc-auth-source-server-function
898@end defopt
899@defopt erc-auth-source-services-function
900@end defopt
901@defopt erc-auth-source-join-function
902
903ERC calls these functions with keyword arguments recognized by
904@code{auth-source-search}, namely, those deemed most relevant to the
905current context, if any. For example, with NickServ queries,
906@code{:user} is the ``desired'' nickname rather than the current one.
907Generalized names, like @code{:user} and @code{:host}, are always used
908over back-end specific ones, like @code{:login} or @code{:machine}.
909ERC expects a string to use as the secret or @code{nil}, if the search
910fails.
911
912@findex erc-auth-source-search
913The default value for all three options is the function
914@code{erc-auth-source-search}. It tries to merge relevant contextual
915parameters with those provided or discovered from the logical connection
916or the underlying transport. Some auth-source back ends may not be
917compatible; netrc, plstore, json, secrets, and pass are currently
918supported.
919@end defopt
920 851
921@subheading Full name 852@subheading Full name
922 853
@@ -946,8 +877,8 @@ This can be either a string or a function to call.
946@end defopt 877@end defopt
947 878
948 879
949@subheading ID
950@anchor{Network Identifier} 880@anchor{Network Identifier}
881@subheading ID
951 882
952ERC uses an abstract designation, called @dfn{network context 883ERC uses an abstract designation, called @dfn{network context
953identifier}, for referring to a connection internally. While normally 884identifier}, for referring to a connection internally. While normally
@@ -1002,7 +933,7 @@ first is lowercase without delims (@samp{deadbeef}) and the second
1002uppercase with colon seps (@samp{DE:AD:BE:EF}). These days, there's 933uppercase with colon seps (@samp{DE:AD:BE:EF}). These days, there's
1003usually a @samp{CERT ADD} command offered by NickServ that can 934usually a @samp{CERT ADD} command offered by NickServ that can
1004register you automatically if you issue it while connected with a 935register you automatically if you issue it while connected with a
1005client cert. (@pxref{ERC client-certificate}). 936client cert. @xref{client-certificate}.
1006 937
1007Additional considerations: 938Additional considerations:
1008@enumerate 939@enumerate
@@ -1038,30 +969,32 @@ ERC> /msg NickServ set property \
1038This should be your network account username, typically the same one 969This should be your network account username, typically the same one
1039registered with nickname services. Specify this when your NickServ 970registered with nickname services. Specify this when your NickServ
1040login differs from the @code{:user} you're connecting with. 971login differs from the @code{:user} you're connecting with.
1041(@pxref{ERC username}) 972@xref{username parameter}.
1042@end defopt 973@end defopt
1043 974
1044@defopt erc-sasl-password 975@defopt erc-sasl-password
1045As noted elsewhere, the @code{:password} parameter for @code{erc-tls} 976As noted elsewhere, the entry-point @code{:password} param was
1046was originally intended for traditional ``server passwords,'' but these 977originally intended for traditional ``server passwords,'' but these
1047aren't really used any more. As such, this option defaults to 978aren't really used any more (@pxref{password parameter}). As such,
1048borrowing that parameter for its own uses, thus allowing you to call 979this option defaults to borrowing that parameter for its own uses,
1049@code{erc-tls} with @code{:password} set to your NickServ password. 980thus allowing you to call @code{erc-tls} with @code{:password} set to
981your NickServ password.
1050 982
1051You can also set this to a nonemtpy string, and ERC will send that 983You can also set this to a nonemtpy string, and ERC will send that
1052when needed, no questions asked. Or, if you'd rather use auth-source, 984when needed, no questions asked. Or, if you'd rather use auth-source,
1053set @code{erc-sasl-auth-source-function} to a function, and ERC will 985set @code{erc-sasl-auth-source-function} to a function, and ERC will
1054perform an auth-source query instead. As last resort in all cases, 986perform an auth-source query instead. In all cases, ERC will prompt
1055ERC will prompt you for input. 987you for input as a last resort.
1056 988
1057Lastly, if your mechanism is @code{ecdsa-nist256p-challenge}, this 989Lastly, if your mechanism is @code{ecdsa-nist256p-challenge}, this
1058option should instead hold the file name of your key. 990option should instead hold the file name of your key.
1059@end defopt 991@end defopt
1060 992
993@anchor{SASL auth-source function}
1061@defopt erc-sasl-auth-source-function 994@defopt erc-sasl-auth-source-function
1062This is nearly identical to the other ERC @samp{auth-source} function 995This is nearly identical to the other ERC @samp{auth-source} function
1063options (@pxref{ERC auth-source functions}) except that the default 996options (@pxref{auth-source functions}) except that the default value
1064value here is @code{nil}, meaning you have to set it to something like 997here is @code{nil}, meaning you have to set it to something like
1065@code{erc-auth-source-search} for queries to be performed. For 998@code{erc-auth-source-search} for queries to be performed. For
1066convenience, this module provides the following as a possible value: 999convenience, this module provides the following as a possible value:
1067 1000
@@ -1163,9 +1096,9 @@ both networks.
1163 1096
1164@subheading Troubleshooting 1097@subheading Troubleshooting
1165 1098
1166@strong{Warning:} ERC's SASL offering is currently limited by a lack 1099First and foremost, please know that ERC's SASL offering is currently
1167of support for proper IRCv3 capability negotiation. In most cases, 1100limited by a lack of support for proper IRCv3 capability negotiation.
1168this shouldn't affect your ability to authenticate. 1101In most cases, this shouldn't affect your ability to authenticate.
1169 1102
1170If you're struggling, remember that your SASL password is almost 1103If you're struggling, remember that your SASL password is almost
1171always your NickServ password. When in doubt, try restoring all SASL 1104always your NickServ password. When in doubt, try restoring all SASL
@@ -1260,12 +1193,19 @@ stuff, to the current ERC buffer."
1260@section Integrations 1193@section Integrations
1261@cindex integrations 1194@cindex integrations
1262 1195
1263@subheading URL 1196@menu
1197* auth-source:: Retrieving auth-source entries with ERC.
1198@end menu
1199
1200@anchor{URL}
1201@subsection URL
1202@cindex URL
1203
1264For anything to work, you'll want to set @code{url-irc-function} to 1204For anything to work, you'll want to set @code{url-irc-function} to
1265@code{url-irc-erc}. As a rule of thumb, libraries relying directly on 1205@code{url-irc-erc}. As a rule of thumb, libraries relying directly on
1266@code{url-retrieve} should be fine out the box from Emacs 29.1 onward. 1206@code{url-retrieve} should be fine out the box from Emacs 29.1 onward.
1267On older versions of Emacs, you may need to @code{(require 'erc)} 1207On older versions of Emacs, you may need to @code{(require 'erc)}
1268beforehand. @pxref{Retrieving URLs,,, url, URL}. 1208beforehand. @xref{Retrieving URLs,,, url, URL}.
1269 1209
1270For other apps and libraries, such as those relying on the 1210For other apps and libraries, such as those relying on the
1271higher-level @code{browse-url}, you'll oftentimes be asked to specify 1211higher-level @code{browse-url}, you'll oftentimes be asked to specify
@@ -1282,6 +1222,160 @@ need a function as well:
1282@noindent 1222@noindent
1283Users on Emacs 28 and below may need to use @code{browse-url} instead. 1223Users on Emacs 28 and below may need to use @code{browse-url} instead.
1284 1224
1225@node auth-source
1226@subsection auth-source
1227@cindex auth-source
1228
1229You can configure ERC to use the built-in auth-source library for
1230looking up passwords. @xref{Top,,auth-source, auth, Emacs auth-source
1231Library}, for general info on setting up various backends, but keep in
1232mind that some of these may not be compatible. Those currently
1233supported are netrc, plstore, json, secrets, and pass. To get started
1234with the default backend, netrc, put a line like the following in your
1235@file{~/.authinfo.gpg} (or any file named in the option
1236@code{auth-sources}):
1237
1238@example
1239machine irc.example.net login mynick password sEcReT
1240@end example
1241
1242@subsubheading Server Passwords
1243When retrieving passwords to accompany the IRC @samp{PASS} command
1244(@pxref{password parameter}), ERC asks auth-source to match the
1245@var{server} parameter of @code{erc-tls} against each entry's
1246@samp{host} field (@w{@code{machine irc.example.net}} in the above
1247example). Unfortunately, specifying a network, like
1248@samp{Libera.Chat}, or a specific network server, like
1249@samp{platinum.libera.chat}, won't normally work for looking up a
1250server password because that information isn't available during
1251opening introductions. (Actually, ERC @emph{can} find entries with
1252arbitrary @samp{host} values for any context, including server
1253passwords, but that requires customizing the more advanced options
1254below.)
1255
1256If ERC can't find a suitable server password, it will just skip the
1257IRC @samp{PASS} command altogether, something users may want when
1258using CertFP or engaging NickServ via ERC's @code{services} module.
1259If that appeals to you, consider customizing the option
1260@code{erc-auth-source-server-function} to @code{nil} to skip
1261server-password lookup for all servers. Note that some networks and
1262IRCds may accept account-services authentication via server password.
1263Also, some ERC modules may commandeer the @code{erc-tls}
1264@var{password} parameter for their own ends, which likely don't
1265involve a server password.
1266
1267@subsubheading The @samp{services} module
1268You can use auth-source to authenticate to account services the
1269traditional way through a bot called @samp{NickServ}. To do so, add
1270@code{services} to @code{erc-modules} and set the option
1271@code{erc-use-auth-source-for-nickserv-password} to @code{t}. After
1272that, expect the @samp{user} parameter in relevant auth-source queries
1273to be your current nickname.
1274
1275Most of the time, a query's precise contextual details (such as
1276whether a nick was granted or forcibly assigned) shouldn't affect how
1277you define entries in your backend. However, if something isn't quite
1278working, you may want to investigate the interplay between the option
1279@code{erc-nickserv-identify-mode} and account services. In
1280particular, if you find yourself facing nicks suffixed with an
1281@code{erc-nick-uniquifier} (the infamous @samp{`}), check that the
1282network's entry in @code{erc-nickserv-alist} is up to date, and do let
1283us know if something's off (@pxref{Getting Help and Reporting Bugs}).
1284Of course, if you've had your fill of fiddling with this module,
1285consider switching to SASL for what's likely a more consistent
1286auth-source experience. (@xref{SASL}.)
1287
1288@subsubheading Default query behavior
1289When preparing entries for your backend, it may help to get a feel for
1290how ERC and its modules conduct searches, especially when exploring a
1291new context, such as channel keys. (Hint: in such situations, try
1292temporarily setting the variable @code{auth-source-debug} to @code{t}
1293and checking @samp{*Messages*} periodically for insights into how
1294auth-source is operating.) Overall, though, ERC tries to be
1295consistent in performing queries across various authentication
1296contexts. Here's what to expect with respect to the @samp{host}
1297field, which, by default, most heavily influences the fate of a query:
1298
1299@enumerate
1300@item
1301entries featuring custom identifiers and networks are matched first
1302(@pxref{Network Identifier})
1303@item
1304followed by network-specific servers
1305@item
1306and, finally, dialed endpoints (typically the @var{server} argument
1307passed to @code{erc-tls})
1308@end enumerate
1309
1310@noindent
1311The following netrc-style entries appear in order of precedence:
1312
1313@example
1314machine Libera/cellphone login MyNick password sEcReT
1315machine Libera.Chat login MyNick password sEcReT
1316machine zirconium.libera.chat login MyNick password sEcReT
1317machine irc.libera.chat login MyNick password sEcReT
1318@end example
1319
1320@noindent
1321Remember that field labels vary per backend, so @samp{machine} (in
1322netrc's case) maps to auth-source's generalized notion of a host,
1323hence the @samp{:host} keyword parameter to @code{auth-source-search}.
1324Also, be sure to mind the syntax of your chosen backend medium. For
1325example, always quote channel names in a netrc file.
1326
1327Lastly, if this all seems overly nuanced or just plain doesn't appeal
1328to you, please see options @code{erc-auth-source-services-function}
1329and friends, described just below.
1330
1331@subsubheading Custom query functions
1332These let you query auth-source your way. Most users can
1333simply ignore the passed-in arguments and get by with something like
1334the following:
1335
1336@lisp
1337(defun my-fancy-auth-source-func (&rest _)
1338 (let* ((host (read-string "host: " nil nil "default"))
1339 (pass (auth-source-pick-first-password :host host)))
1340 (if (and pass (string-search "libera" host))
1341 (concat "MyNick:" pass)
1342 pass)))
1343@end lisp
1344
1345@anchor{auth-source functions}
1346@defopt erc-auth-source-server-function
1347@end defopt
1348@defopt erc-auth-source-services-function
1349@end defopt
1350@defopt erc-auth-source-join-function
1351
1352ERC calls these functions with keyword arguments recognized by
1353@code{auth-source-search}, namely, those deemed most relevant to the
1354current context, if any. For example, when identifying to services,
1355@code{:user} contains your current nickname. Generalized parameter
1356names, like @code{:user} and @code{:host}, are always preferred over
1357backend specific ones, like @code{:login} or @code{:machine}. In
1358return, ERC expects a string if the search succeeds or @code{nil} if
1359it fails.
1360
1361@findex erc-auth-source-search
1362The default value for all three options is the function
1363@code{erc-auth-source-search}. It tries to merge relevant contextual
1364parameters with those provided or discovered from the logical
1365connection or the underlying transport.
1366
1367For using auth-source along with SASL, @pxref{SASL auth-source
1368function}.
1369@end defopt
1370
1371@subsubheading Channel keys
1372ERC also consults @code{auth-source} to find ``keys'' that may be
1373required by certain channels you join. When modifying a traditional
1374@code{auth-source} entry for this purpose, put the channel name in the
1375@samp{user} field (for example, @samp{login "#fsf"}, in netrc's case).
1376The actual key goes in the @samp{password} (or @samp{secret}) field.
1377
1378
1285@node Options 1379@node Options
1286@section Options 1380@section Options
1287@cindex options 1381@cindex options