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

Fix auth-source.el doc

* doc/misc/auth.texi (Help for users): Change variables to user
options where appropriate.  Use setopt for them.  Add Tramp link.
Fix example.  (Bug#9113)

* lisp/auth-source.el (auth-sources): Add :link.
This commit is contained in:
Michael Albinus 2025-09-07 12:18:42 +02:00
parent 5e57829ffd
commit 96d9040341
2 changed files with 36 additions and 34 deletions

View file

@ -163,7 +163,7 @@ problems, your first step is always to see what's being checked. The
second step, of course, is to write a blog entry about it and wait for second step, of course, is to write a blog entry about it and wait for
the answer in the comments. the answer in the comments.
You can customize the variable @code{auth-sources}. The following may You can customize the user option @code{auth-sources}. The following may
be needed if you are using an older version of Emacs or if the be needed if you are using an older version of Emacs or if the
auth-source library is not loaded for some other reason. auth-source library is not loaded for some other reason.
@ -172,29 +172,29 @@ auth-source library is not loaded for some other reason.
(customize-variable 'auth-sources) ;; optional, do it once (customize-variable 'auth-sources) ;; optional, do it once
@end lisp @end lisp
@defvar auth-sources @defopt auth-sources
The @code{auth-sources} variable tells the auth-source library where The @code{auth-sources} user option tells the auth-source library where
your netrc files, Secret Service API collection items, or your your netrc files, Secret Service API collection items, or your
password store live for a particular host and protocol. While you can password store live for a particular host and protocol. While you can
get fancy, the default and simplest configuration is: get fancy, the default and simplest configuration is:
@lisp @lisp
;;; old default: required :host and :port, not needed anymore ;;; old default: required :host and :port, not needed anymore
(setq auth-sources '((:source "~/.authinfo.gpg" :host t :port t))) (setopt auth-sources '((:source "~/.authinfo.gpg" :host t :port t)))
;;; mostly equivalent (see below about fallbacks) but shorter: ;;; mostly equivalent (see below about fallbacks) but shorter:
(setq auth-sources '((:source "~/.authinfo.gpg"))) (setopt auth-sources '((:source "~/.authinfo.gpg")))
;;; even shorter and the @emph{default}: ;;; even shorter:
(setq auth-sources '("~/.authinfo.gpg" "~/.authinfo" "~/.netrc")) (setopt auth-sources '("~/.authinfo.gpg"))
;;; use the Secrets API @var{Login} collection ;;; use the Secrets API @var{Login} collection
;;; (@pxref{Secret Service API}) ;;; (@pxref{Secret Service API})
(setq auth-sources '("secrets:Login")) (setopt auth-sources '("secrets:Login"))
;;; use pass (@file{~/.password-store}) ;;; use pass (@file{~/.password-store})
;;; (@pxref{The Unix password store}) ;;; (@pxref{The Unix password store})
(auth-source-pass-enable) (auth-source-pass-enable)
;;; JSON data in format [@{ "machine": "SERVER", ;;; JSON data in format [@{ "machine": "SERVER",
;;; "login": "USER", "password": "PASSWORD" @}...] ;;; "login": "USER", "password": "PASSWORD" @}...]
(setq auth-sources '("~/.authinfo.json.gpg")) (setopt auth-sources '("~/.authinfo.json.gpg"))
@end lisp @end lisp
By adding multiple entries to @code{auth-sources} with a particular By adding multiple entries to @code{auth-sources} with a particular
@ -206,12 +206,12 @@ have unusual setups and the remaining 10% are @emph{really} unusual).
Here's a mixed example using two sources: Here's a mixed example using two sources:
@lisp @lisp
(setq auth-sources '((:source (:secrets default) (setopt auth-sources '((:source (:secrets default)
:host "myserver" :user "joe") :host "myserver" :user "joe")
"~/.authinfo.gpg")) "~/.authinfo.gpg"))
@end lisp @end lisp
@end defvar @end defopt
If you don't customize @code{auth-sources}, you'll have to live with If you don't customize @code{auth-sources}, you'll have to live with
the defaults: the unencrypted netrc file @file{~/.authinfo} will be the defaults: the unencrypted netrc file @file{~/.authinfo} will be
@ -265,6 +265,7 @@ Note that the port denotes the Tramp connection method. When you
don't use a port entry, you match any Tramp method, as explained don't use a port entry, you match any Tramp method, as explained
earlier. Since Tramp has about 88 connection methods, this may be earlier. Since Tramp has about 88 connection methods, this may be
necessary if you have an unusual (see earlier comment on those) setup. necessary if you have an unusual (see earlier comment on those) setup.
@xref{Password handling, Password handling,, tramp, Tramp}.
The netrc format is directly translated into JSON, if you are into The netrc format is directly translated into JSON, if you are into
that sort of thing. Just point to a JSON file with entries like this: that sort of thing. Just point to a JSON file with entries like this:
@ -285,9 +286,9 @@ names:
@example @example
(setq gnus-secondary-select-methods '((nnimap "gmail" (setq gnus-secondary-select-methods '((nnimap "gmail"
(nnimap-address "imap.gmail.com")) (nnimap-address "imap.gmail.com"))
(nnimap "gmail2" (nnimap "gmail2"
(nnimap-address "imap.gmail.com")))) (nnimap-address "imap.gmail.com"))))
@end example @end example
Your netrc entries will then be: Your netrc entries will then be:
@ -460,10 +461,10 @@ example that sets @code{auth-sources} to search three collections and
then fall back to @file{~/.authinfo.gpg}. then fall back to @file{~/.authinfo.gpg}.
@example @example
(setq auth-sources '(default (setopt auth-sources '(default
"secrets:session" "secrets:session"
"secrets:Login" "secrets:Login"
"~/.authinfo.gpg")) "~/.authinfo.gpg"))
@end example @end example
Attribute values in the auth-source spec, which are not strings (like Attribute values in the auth-source spec, which are not strings (like
@ -477,7 +478,7 @@ functions.
manager} (or just @samp{pass}) stores your passwords in manager} (or just @samp{pass}) stores your passwords in
@code{gpg}-protected files following the Unix philosophy. The store @code{gpg}-protected files following the Unix philosophy. The store
location (any directory) must be specified in the location (any directory) must be specified in the
@code{auth-source-pass-filename} variable which defaults to @code{auth-source-pass-filename} user option which defaults to
@file{~/.password-store}. @file{~/.password-store}.
Emacs integration of @samp{pass} follows the approach suggested by the Emacs integration of @samp{pass} follows the approach suggested by the
@ -503,7 +504,7 @@ host with an at-sign (@code{@@}).
@item gnu.org:22.gpg @item gnu.org:22.gpg
The port (aka. service) to match can only be expressed after the host The port (aka. service) to match can only be expressed after the host
and separated with a colon (@code{:}). The separator can be changed and separated with a colon (@code{:}). The separator can be changed
through the @code{auth-source-pass-port-separator} variable. through the @code{auth-source-pass-port-separator} user option.
@item gnu.org:22/rms.gpg @item gnu.org:22/rms.gpg
@ -544,17 +545,17 @@ library wrapping @samp{pass};
@uref{https://github.com/jabranham/helm-pass,,helm-pass}: helm interface for pass. @uref{https://github.com/jabranham/helm-pass,,helm-pass}: helm interface for pass.
@end itemize @end itemize
@defvar auth-source-pass-filename @defopt auth-source-pass-filename
Set this variable to a string locating the password store on the disk. Set this user option to a string locating the password store on the disk.
Defaults to @file{~/.password-store}. Defaults to @file{~/.password-store}.
@end defvar @end defopt
@defvar auth-source-pass-port-separator @defopt auth-source-pass-port-separator
Set this variable to a string that should separate an host name from a Set this user option to a string that should separate an host name from a
port in an entry. Defaults to @samp{:}. port in an entry. Defaults to @samp{:}.
@end defvar @end defopt
@defvar auth-source-pass-extra-query-keywords @defopt auth-source-pass-extra-query-keywords
This expands the selection of available keywords to include This expands the selection of available keywords to include
@code{:max} and @code{:require} and tells more of them to accept a @code{:max} and @code{:require} and tells more of them to accept a
list of query parameters as an argument. When searching, it also list of query parameters as an argument. When searching, it also
@ -569,18 +570,18 @@ matching against subdomain labels, keep this option set to @code{nil}
of searches relative to other auth-source backends or encounter code of searches relative to other auth-source backends or encounter code
expecting to query multiple backends uniformly, try flipping it to expecting to query multiple backends uniformly, try flipping it to
@code{t}. @code{t}.
@end defvar @end defopt
@node Help for developers @node Help for developers
@chapter Help for developers @chapter Help for developers
The auth-source library lets you control logging output easily. The auth-source library lets you control logging output easily.
@defvar auth-source-debug @defopt auth-source-debug
Set this variable to @code{'trivia} to see lots of output in Set this user option to @code{'trivia} to see lots of output in
@file{*Messages*}, or set it to a function that behaves like @file{*Messages*}, or set it to a function that behaves like
@code{message} to do your own logging. @code{message} to do your own logging.
@end defvar @end defopt
The auth-source library only has a few functions for external use. The auth-source library only has a few functions for external use.
@ -671,7 +672,7 @@ record.
@node GnuPG and EasyPG Assistant Configuration @node GnuPG and EasyPG Assistant Configuration
@appendix GnuPG and EasyPG Assistant Configuration @appendix GnuPG and EasyPG Assistant Configuration
If the @code{auth-sources} variable contains @file{~/.authinfo.gpg} If the @code{auth-sources} user option contains @file{~/.authinfo.gpg}
before @file{~/.authinfo}, the auth-source library will try to before @file{~/.authinfo}, the auth-source library will try to
read the GnuPG encrypted @file{.gpg} file first, before read the GnuPG encrypted @file{.gpg} file first, before
the unencrypted file. the unencrypted file.

View file

@ -301,7 +301,8 @@ the choices can get pretty complex."
(const :tag "Any" t) (const :tag "Any" t)
(string (string
:tag "Name")))))) :tag "Name"))))))
(sexp :tag "A data structure (external provider)")))) (sexp :tag "A data structure (external provider)")))
:link '(custom-manual "(auth) Help for users"))
(defcustom auth-source-gpg-encrypt-to t (defcustom auth-source-gpg-encrypt-to t
"List of recipient keys that `authinfo.gpg' encrypted to. "List of recipient keys that `authinfo.gpg' encrypted to.