diff options
| author | F. Jason Park | 2022-11-30 23:10:58 -0800 |
|---|---|---|
| committer | F. Jason Park | 2022-12-14 06:40:55 -0800 |
| commit | 9ac80e8a6e4969cfe88d5233dc4152bbfa46c848 (patch) | |
| tree | cd44b91bd46448e66e66c9cbbed0dc07cb58c2d6 /doc | |
| parent | 2d96a18cd09be1c53b1242be1e0671cfc5b7fa8c (diff) | |
| download | emacs-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')
| -rw-r--r-- | doc/misc/erc.texi | 344 |
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 | |||
| 581 | Integrations | ||
| 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 | |||
| 643 | parameters, and some, like @code{client-certificate}, will just be | 653 | parameters, 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} |
| 647 | To use a certificate with @code{erc-tls}, specify the optional | 657 | To 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 |
| 649 | described in the documentation of @code{open-network-stream}: if | 659 | described 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}. |
| 700 | For other uses of auth-source throughout ERC, @pxref{auth-source, | ||
| 701 | ERC'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. | |||
| 778 | You can manually set another nickname with the /NICK command. | 790 | You 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 |
| 786 | Determine a suitable value to send as the first argument of the | 798 | Determine 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 | |||
| 803 | a string abiding by the rules of the network. | 815 | a 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 | |
| 823 | This parameter was traditionally meant to specify a @dfn{server | ||
| 824 | password} to be sent along with the IRC @samp{PASS} command. However, | ||
| 825 | such passwords aren't widely used. Instead, networks typically expect | ||
| 826 | them, when present, to convey other authentication information. In | ||
| 827 | the case of account-services (a.k.a., ``NickServ'') credentials, this | ||
| 828 | typically involves a special syntax, such as @samp{myuser:mypass}. | ||
| 829 | IRC bouncers often do something similar but include a pre-configured | ||
| 830 | network-ID component, for example, @samp{bncuser/mynet:bncpass}. | ||
| 831 | |||
| 832 | In general, if you have @emph{not} been asked by your network or | ||
| 833 | bouncer to specify a repurposed server password, you should instead | ||
| 834 | consider setting up @samp{services} or, preferably, @samp{sasl}, both | ||
| 835 | ERC modules (@pxref{Modules}). In addition to performing | ||
| 836 | network-account authentication, these obviate the need for this | ||
| 837 | parameter completely, although both can optionally borrow it for their | ||
| 838 | own purposes. (@xref{SASL, SASL in ERC}.) | ||
| 808 | 839 | ||
| 809 | @defopt erc-prompt-for-password | 840 | @defopt erc-prompt-for-password |
| 810 | If non-@code{nil} (the default), @kbd{M-x erc} and @kbd{M-x erc-tls} | 841 | If 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 |
| 816 | If you prefer, you can set this option to @code{nil} and use the | 847 | If 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 | 848 | auth-source facility to retrieve a server password, although hitting |
| 818 | the option @code{auth-sources} contains @file{~/.authinfo}, put | 849 | @kbd{RET} at the prompt may achieve the same effect. |
| 819 | something like the following in that file: | 850 | @xref{auth-source, ERC's auth-source integration}, for more. |
| 820 | |||
| 821 | @example | ||
| 822 | machine irc.example.net login mynick password sEcReT | ||
| 823 | @end example | ||
| 824 | |||
| 825 | @noindent | ||
| 826 | For server passwords, that is, passwords sent for the IRC @samp{PASS} | ||
| 827 | command, the @samp{host} field (@w{@code{machine irc.example.net}} in | ||
| 828 | the above example) | ||
| 829 | corresponds 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 | ||
| 833 | password because such information isn't available during opening | ||
| 834 | introductions. (Actually, ERC @emph{can} find entries with arbitrary | ||
| 835 | @samp{host} values for any context, including server passwords, but | ||
| 836 | that requires customizing the more advanced options below.) | ||
| 837 | |||
| 838 | If 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 | ||
| 840 | CertFP or engaging NickServ via ERC's ``services'' module. If that is | ||
| 841 | what you'd like to do, you can also customize the option | ||
| 842 | @code{erc-auth-source-server-function} to @code{nil} to skip | ||
| 843 | server-password lookup for all servers. Note that some networks and | ||
| 844 | IRCds may accept account-services authentication via server password | ||
| 845 | using the nonstandard @samp{mynick:sEcReT} convention. | ||
| 846 | |||
| 847 | As just mentioned, you can also use @code{auth-source} to authenticate | ||
| 848 | to 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 | ||
| 851 | these and most other queries, entries featuring custom identifiers and | ||
| 852 | networks are matched first, followed by network-specific servers and | ||
| 853 | dialed endpoints (typically, the @var{server} argument passed to | ||
| 854 | @code{erc}). The following netrc-style entries appear in order of | ||
| 855 | precedence: | ||
| 856 | |||
| 857 | @example | ||
| 858 | machine Libera/cellphone login MyNick password sEcReT | ||
| 859 | machine Libera.Chat login MyNick password sEcReT | ||
| 860 | machine zirconium.libera.chat login MyNick password sEcReT | ||
| 861 | machine irc.libera.chat login MyNick password sEcReT | ||
| 862 | @end example | ||
| 863 | |||
| 864 | @noindent | ||
| 865 | Remember that field labels vary per backend, so @samp{machine} (in | ||
| 866 | netrc's case) maps to auth-source's generalized notion of a host, | ||
| 867 | hence the @samp{:host} keyword property. Also, be sure to mind the | ||
| 868 | syntax of your chosen backend medium. For example, always quote | ||
| 869 | channel names in a netrc file. | ||
| 870 | |||
| 871 | If this all seems overly nuanced or just plain doesn't appeal to you, | ||
| 872 | see options @code{erc-auth-source-services-function} and friends, described | ||
| 873 | below. These let you query auth-source your way. Most users can | ||
| 874 | simply ignore the passed-in arguments and get by with something like | ||
| 875 | the 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 | |||
| 886 | Lastly, ERC also consults @code{auth-source} to find ``keys'' that may | ||
| 887 | be required by certain channels you join. When modifying a | ||
| 888 | traditional @code{auth-source} entry for this purpose, put the channel | ||
| 889 | name in the @samp{user} field (for example, @samp{login "#fsf"}, in | ||
| 890 | netrc's case). The actual key goes in the @samp{password} (or | ||
| 891 | @samp{secret}) field. | ||
| 892 | |||
| 893 | @noindent | ||
| 894 | For 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 | |||
| 903 | ERC calls these functions with keyword arguments recognized by | ||
| 904 | @code{auth-source-search}, namely, those deemed most relevant to the | ||
| 905 | current context, if any. For example, with NickServ queries, | ||
| 906 | @code{:user} is the ``desired'' nickname rather than the current one. | ||
| 907 | Generalized names, like @code{:user} and @code{:host}, are always used | ||
| 908 | over back-end specific ones, like @code{:login} or @code{:machine}. | ||
| 909 | ERC expects a string to use as the secret or @code{nil}, if the search | ||
| 910 | fails. | ||
| 911 | |||
| 912 | @findex erc-auth-source-search | ||
| 913 | The default value for all three options is the function | ||
| 914 | @code{erc-auth-source-search}. It tries to merge relevant contextual | ||
| 915 | parameters with those provided or discovered from the logical connection | ||
| 916 | or the underlying transport. Some auth-source back ends may not be | ||
| 917 | compatible; netrc, plstore, json, secrets, and pass are currently | ||
| 918 | supported. | ||
| 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 | ||
| 952 | ERC uses an abstract designation, called @dfn{network context | 883 | ERC uses an abstract designation, called @dfn{network context |
| 953 | identifier}, for referring to a connection internally. While normally | 884 | identifier}, for referring to a connection internally. While normally |
| @@ -1002,7 +933,7 @@ first is lowercase without delims (@samp{deadbeef}) and the second | |||
| 1002 | uppercase with colon seps (@samp{DE:AD:BE:EF}). These days, there's | 933 | uppercase with colon seps (@samp{DE:AD:BE:EF}). These days, there's |
| 1003 | usually a @samp{CERT ADD} command offered by NickServ that can | 934 | usually a @samp{CERT ADD} command offered by NickServ that can |
| 1004 | register you automatically if you issue it while connected with a | 935 | register you automatically if you issue it while connected with a |
| 1005 | client cert. (@pxref{ERC client-certificate}). | 936 | client cert. @xref{client-certificate}. |
| 1006 | 937 | ||
| 1007 | Additional considerations: | 938 | Additional considerations: |
| 1008 | @enumerate | 939 | @enumerate |
| @@ -1038,30 +969,32 @@ ERC> /msg NickServ set property \ | |||
| 1038 | This should be your network account username, typically the same one | 969 | This should be your network account username, typically the same one |
| 1039 | registered with nickname services. Specify this when your NickServ | 970 | registered with nickname services. Specify this when your NickServ |
| 1040 | login differs from the @code{:user} you're connecting with. | 971 | login 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 |
| 1045 | As noted elsewhere, the @code{:password} parameter for @code{erc-tls} | 976 | As noted elsewhere, the entry-point @code{:password} param was |
| 1046 | was originally intended for traditional ``server passwords,'' but these | 977 | originally intended for traditional ``server passwords,'' but these |
| 1047 | aren't really used any more. As such, this option defaults to | 978 | aren't really used any more (@pxref{password parameter}). As such, |
| 1048 | borrowing that parameter for its own uses, thus allowing you to call | 979 | this option defaults to borrowing that parameter for its own uses, |
| 1049 | @code{erc-tls} with @code{:password} set to your NickServ password. | 980 | thus allowing you to call @code{erc-tls} with @code{:password} set to |
| 981 | your NickServ password. | ||
| 1050 | 982 | ||
| 1051 | You can also set this to a nonemtpy string, and ERC will send that | 983 | You can also set this to a nonemtpy string, and ERC will send that |
| 1052 | when needed, no questions asked. Or, if you'd rather use auth-source, | 984 | when needed, no questions asked. Or, if you'd rather use auth-source, |
| 1053 | set @code{erc-sasl-auth-source-function} to a function, and ERC will | 985 | set @code{erc-sasl-auth-source-function} to a function, and ERC will |
| 1054 | perform an auth-source query instead. As last resort in all cases, | 986 | perform an auth-source query instead. In all cases, ERC will prompt |
| 1055 | ERC will prompt you for input. | 987 | you for input as a last resort. |
| 1056 | 988 | ||
| 1057 | Lastly, if your mechanism is @code{ecdsa-nist256p-challenge}, this | 989 | Lastly, if your mechanism is @code{ecdsa-nist256p-challenge}, this |
| 1058 | option should instead hold the file name of your key. | 990 | option 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 |
| 1062 | This is nearly identical to the other ERC @samp{auth-source} function | 995 | This is nearly identical to the other ERC @samp{auth-source} function |
| 1063 | options (@pxref{ERC auth-source functions}) except that the default | 996 | options (@pxref{auth-source functions}) except that the default value |
| 1064 | value here is @code{nil}, meaning you have to set it to something like | 997 | here 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 |
| 1066 | convenience, this module provides the following as a possible value: | 999 | convenience, 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 | 1099 | First and foremost, please know that ERC's SASL offering is currently |
| 1167 | of support for proper IRCv3 capability negotiation. In most cases, | 1100 | limited by a lack of support for proper IRCv3 capability negotiation. |
| 1168 | this shouldn't affect your ability to authenticate. | 1101 | In most cases, this shouldn't affect your ability to authenticate. |
| 1169 | 1102 | ||
| 1170 | If you're struggling, remember that your SASL password is almost | 1103 | If you're struggling, remember that your SASL password is almost |
| 1171 | always your NickServ password. When in doubt, try restoring all SASL | 1104 | always 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 | |||
| 1264 | For anything to work, you'll want to set @code{url-irc-function} to | 1204 | For 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. |
| 1267 | On older versions of Emacs, you may need to @code{(require 'erc)} | 1207 | On older versions of Emacs, you may need to @code{(require 'erc)} |
| 1268 | beforehand. @pxref{Retrieving URLs,,, url, URL}. | 1208 | beforehand. @xref{Retrieving URLs,,, url, URL}. |
| 1269 | 1209 | ||
| 1270 | For other apps and libraries, such as those relying on the | 1210 | For other apps and libraries, such as those relying on the |
| 1271 | higher-level @code{browse-url}, you'll oftentimes be asked to specify | 1211 | higher-level @code{browse-url}, you'll oftentimes be asked to specify |
| @@ -1282,6 +1222,160 @@ need a function as well: | |||
| 1282 | @noindent | 1222 | @noindent |
| 1283 | Users on Emacs 28 and below may need to use @code{browse-url} instead. | 1223 | Users 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 | |||
| 1229 | You can configure ERC to use the built-in auth-source library for | ||
| 1230 | looking up passwords. @xref{Top,,auth-source, auth, Emacs auth-source | ||
| 1231 | Library}, for general info on setting up various backends, but keep in | ||
| 1232 | mind that some of these may not be compatible. Those currently | ||
| 1233 | supported are netrc, plstore, json, secrets, and pass. To get started | ||
| 1234 | with 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 | ||
| 1239 | machine irc.example.net login mynick password sEcReT | ||
| 1240 | @end example | ||
| 1241 | |||
| 1242 | @subsubheading Server Passwords | ||
| 1243 | When 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 | ||
| 1247 | example). 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 | ||
| 1250 | server password because that information isn't available during | ||
| 1251 | opening introductions. (Actually, ERC @emph{can} find entries with | ||
| 1252 | arbitrary @samp{host} values for any context, including server | ||
| 1253 | passwords, but that requires customizing the more advanced options | ||
| 1254 | below.) | ||
| 1255 | |||
| 1256 | If ERC can't find a suitable server password, it will just skip the | ||
| 1257 | IRC @samp{PASS} command altogether, something users may want when | ||
| 1258 | using CertFP or engaging NickServ via ERC's @code{services} module. | ||
| 1259 | If that appeals to you, consider customizing the option | ||
| 1260 | @code{erc-auth-source-server-function} to @code{nil} to skip | ||
| 1261 | server-password lookup for all servers. Note that some networks and | ||
| 1262 | IRCds may accept account-services authentication via server password. | ||
| 1263 | Also, some ERC modules may commandeer the @code{erc-tls} | ||
| 1264 | @var{password} parameter for their own ends, which likely don't | ||
| 1265 | involve a server password. | ||
| 1266 | |||
| 1267 | @subsubheading The @samp{services} module | ||
| 1268 | You can use auth-source to authenticate to account services the | ||
| 1269 | traditional 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 | ||
| 1272 | that, expect the @samp{user} parameter in relevant auth-source queries | ||
| 1273 | to be your current nickname. | ||
| 1274 | |||
| 1275 | Most of the time, a query's precise contextual details (such as | ||
| 1276 | whether a nick was granted or forcibly assigned) shouldn't affect how | ||
| 1277 | you define entries in your backend. However, if something isn't quite | ||
| 1278 | working, you may want to investigate the interplay between the option | ||
| 1279 | @code{erc-nickserv-identify-mode} and account services. In | ||
| 1280 | particular, if you find yourself facing nicks suffixed with an | ||
| 1281 | @code{erc-nick-uniquifier} (the infamous @samp{`}), check that the | ||
| 1282 | network's entry in @code{erc-nickserv-alist} is up to date, and do let | ||
| 1283 | us know if something's off (@pxref{Getting Help and Reporting Bugs}). | ||
| 1284 | Of course, if you've had your fill of fiddling with this module, | ||
| 1285 | consider switching to SASL for what's likely a more consistent | ||
| 1286 | auth-source experience. (@xref{SASL}.) | ||
| 1287 | |||
| 1288 | @subsubheading Default query behavior | ||
| 1289 | When preparing entries for your backend, it may help to get a feel for | ||
| 1290 | how ERC and its modules conduct searches, especially when exploring a | ||
| 1291 | new context, such as channel keys. (Hint: in such situations, try | ||
| 1292 | temporarily setting the variable @code{auth-source-debug} to @code{t} | ||
| 1293 | and checking @samp{*Messages*} periodically for insights into how | ||
| 1294 | auth-source is operating.) Overall, though, ERC tries to be | ||
| 1295 | consistent in performing queries across various authentication | ||
| 1296 | contexts. Here's what to expect with respect to the @samp{host} | ||
| 1297 | field, which, by default, most heavily influences the fate of a query: | ||
| 1298 | |||
| 1299 | @enumerate | ||
| 1300 | @item | ||
| 1301 | entries featuring custom identifiers and networks are matched first | ||
| 1302 | (@pxref{Network Identifier}) | ||
| 1303 | @item | ||
| 1304 | followed by network-specific servers | ||
| 1305 | @item | ||
| 1306 | and, finally, dialed endpoints (typically the @var{server} argument | ||
| 1307 | passed to @code{erc-tls}) | ||
| 1308 | @end enumerate | ||
| 1309 | |||
| 1310 | @noindent | ||
| 1311 | The following netrc-style entries appear in order of precedence: | ||
| 1312 | |||
| 1313 | @example | ||
| 1314 | machine Libera/cellphone login MyNick password sEcReT | ||
| 1315 | machine Libera.Chat login MyNick password sEcReT | ||
| 1316 | machine zirconium.libera.chat login MyNick password sEcReT | ||
| 1317 | machine irc.libera.chat login MyNick password sEcReT | ||
| 1318 | @end example | ||
| 1319 | |||
| 1320 | @noindent | ||
| 1321 | Remember that field labels vary per backend, so @samp{machine} (in | ||
| 1322 | netrc's case) maps to auth-source's generalized notion of a host, | ||
| 1323 | hence the @samp{:host} keyword parameter to @code{auth-source-search}. | ||
| 1324 | Also, be sure to mind the syntax of your chosen backend medium. For | ||
| 1325 | example, always quote channel names in a netrc file. | ||
| 1326 | |||
| 1327 | Lastly, if this all seems overly nuanced or just plain doesn't appeal | ||
| 1328 | to you, please see options @code{erc-auth-source-services-function} | ||
| 1329 | and friends, described just below. | ||
| 1330 | |||
| 1331 | @subsubheading Custom query functions | ||
| 1332 | These let you query auth-source your way. Most users can | ||
| 1333 | simply ignore the passed-in arguments and get by with something like | ||
| 1334 | the 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 | |||
| 1352 | ERC calls these functions with keyword arguments recognized by | ||
| 1353 | @code{auth-source-search}, namely, those deemed most relevant to the | ||
| 1354 | current context, if any. For example, when identifying to services, | ||
| 1355 | @code{:user} contains your current nickname. Generalized parameter | ||
| 1356 | names, like @code{:user} and @code{:host}, are always preferred over | ||
| 1357 | backend specific ones, like @code{:login} or @code{:machine}. In | ||
| 1358 | return, ERC expects a string if the search succeeds or @code{nil} if | ||
| 1359 | it fails. | ||
| 1360 | |||
| 1361 | @findex erc-auth-source-search | ||
| 1362 | The default value for all three options is the function | ||
| 1363 | @code{erc-auth-source-search}. It tries to merge relevant contextual | ||
| 1364 | parameters with those provided or discovered from the logical | ||
| 1365 | connection or the underlying transport. | ||
| 1366 | |||
| 1367 | For using auth-source along with SASL, @pxref{SASL auth-source | ||
| 1368 | function}. | ||
| 1369 | @end defopt | ||
| 1370 | |||
| 1371 | @subsubheading Channel keys | ||
| 1372 | ERC also consults @code{auth-source} to find ``keys'' that may be | ||
| 1373 | required 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). | ||
| 1376 | The 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 |