1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Support checking auth-source for NickServ password for rcirc

* doc/misc/rcirc.texi: Mention new feature.
* etc/NEWS: Mention new feature.
* lisp/net/rcirc.el (rcirc-authinfo): Update type and documentation.
(rcirc-authenticate): Handle a special type to indicate that the
password is stored via auth-source.
This commit is contained in:
Philip Kaludercic 2025-06-09 15:13:19 +02:00
parent 2438aaf764
commit 1009e3d1fd
No known key found for this signature in database
3 changed files with 57 additions and 35 deletions

View file

@ -595,6 +595,10 @@ Before you can use this method, you will have to register your nick and
pick a password for it. Contact @code{nickserv} and check out the pick a password for it. Contact @code{nickserv} and check out the
details. (Using @code{/msg nickserv help}, for example.) details. (Using @code{/msg nickserv help}, for example.)
You can set the password to the symbol @code{:auth-source}, to fetch the
password from auth-source (@pxref{auth-source}), if you to not hard-code
your password in your configuration.
@item chanserv @item chanserv
@cindex chanserv authentication @cindex chanserv authentication
Use this symbol if you need to identify yourself as follows if you want Use this symbol if you need to identify yourself as follows if you want

View file

@ -1891,6 +1891,13 @@ the command will only copy those files.
+++ +++
*** package-x.el is now obsolete. *** package-x.el is now obsolete.
** RCIRC
+++
*** Authentication via NickServ can access password from 'auth-source'
For details, consult 'rcirc-authinfo'.
** Xref ** Xref
--- ---

View file

@ -270,8 +270,13 @@ The ARGUMENTS for each METHOD symbol are:
`sasl': NICK PASSWORD `sasl': NICK PASSWORD
`certfp': KEY CERT `certfp': KEY CERT
For `nickserv', PASSWORD may be the symbol `:auth-source', in which case
the host, nick and port will be used to query a password from an
available `auth-source' backend.
Examples: Examples:
((\"Libera.Chat\" nickserv \"bob\" \"p455w0rd\") ((\"Libera.Chat\" nickserv \"bob\" \"p455w0rd\")
(\"Libera.Chat\" nickserv \"bob\" :auth-source)
(\"Libera.Chat\" chanserv \"bob\" \"#bobland\" \"passwd99\") (\"Libera.Chat\" chanserv \"bob\" \"#bobland\" \"passwd99\")
(\"Libera.Chat\" certfp \"/path/to/key\" \"/path/to/cert\") (\"Libera.Chat\" certfp \"/path/to/key\" \"/path/to/cert\")
(\"bitlbee\" bitlbee \"robert\" \"sekrit\") (\"bitlbee\" bitlbee \"robert\" \"sekrit\")
@ -282,7 +287,9 @@ Examples:
:value-type (choice (list :tag "NickServ" :value-type (choice (list :tag "NickServ"
(const nickserv) (const nickserv)
(string :tag "Nick") (string :tag "Nick")
(string :tag "Password")) (choice
(string :tag "Password")
(const :tag "Use Auth-Source" :auth-source)))
(list :tag "ChanServ" (list :tag "ChanServ"
(const chanserv) (const chanserv)
(string :tag "Nick") (string :tag "Nick")
@ -3666,40 +3673,44 @@ specified in RFC2812, where 005 stood for RPL_BOUNCE."
Passwords are stored in `rcirc-authinfo' (which see)." Passwords are stored in `rcirc-authinfo' (which see)."
(interactive) (interactive)
(with-rcirc-server-buffer (with-rcirc-server-buffer
(dolist (i rcirc-authinfo) (pcase-dolist (`(,(rx (regexp rcirc-server)) . ,ai) rcirc-authinfo)
(let ((process (rcirc-buffer-process)) (pcase ai
(server (car i)) (`(nickserv ,(rx (regexp rcirc-nick)) :auth-source . ,(or `(,nickserv) '()))
(nick (nth 2 i)) (if-let* ((auth (auth-source-search
(method (cadr i)) :host rcirc-server
(args (cdddr i))) :port (nth 1 rcirc-connection-info)
(when (and (string-match server rcirc-server)) :user (nth 2 rcirc-connection-info)))
(if (and (memq method '(nickserv chanserv bitlbee)) (password (auth-info-password (car auth))))
(string-match nick rcirc-nick))
;; the following methods rely on the user's nickname.
(cl-case method
(nickserv
(rcirc-send-privmsg (rcirc-send-privmsg
process (rcirc-buffer-process)
(or (cadr args) "NickServ") (or nickserv "NickServ")
(concat "IDENTIFY " (car args)))) (concat "IDENTIFY " password))
(chanserv (rcirc-print
(rcirc-buffer-process) rcirc-nick "ERROR" nil
"No auth-source entry found for `nickserv' authentication")))
(`(nickserv ,(rx (regexp rcirc-nick)) ,password . ,(or `(,nickserv) '()))
(rcirc-send-privmsg (rcirc-send-privmsg
process (rcirc-buffer-process)
(or nickserv "NickServ")
(concat "IDENTIFY " password)))
(`(chanserv ,(rx (regexp rcirc-nick)) ,channel ,password)
(rcirc-send-privmsg
(rcirc-buffer-process)
"ChanServ" "ChanServ"
(format "IDENTIFY %s %s" (car args) (cadr args)))) (format "IDENTIFY %s %s" channel password)))
(bitlbee (`(bitlbee ,(rx (regexp rcirc-nick)) ,password)
(rcirc-send-privmsg (rcirc-send-privmsg
process (rcirc-buffer-process)
"&bitlbee" "&bitlbee"
(concat "IDENTIFY " (car args)))) (concat "IDENTIFY " password)))
(sasl nil)) (`(quakenet ,account ,password)
;; quakenet authentication doesn't rely on the user's nickname. ;; quakenet authentication doesn't rely on the user's
;; the variable `nick' here represents the Q account name. ;; nickname. the variable `account' here represents the Q
(when (eq method 'quakenet) ;; account name.
(rcirc-send-privmsg (rcirc-send-privmsg
process (rcirc-buffer-process)
"Q@CServe.quakenet.org" "Q@CServe.quakenet.org"
(format "AUTH %s %s" nick (car args)))))))))) (format "AUTH %s %s" account password)))))))
(defun rcirc-handler-INVITE (process sender args _text) (defun rcirc-handler-INVITE (process sender args _text)
"Notify user of an invitation from SENDER. "Notify user of an invitation from SENDER.