Add convenience function to retrieve auth-source entries

Again inspired by https://magnus.therning.org/2024-09-01-improving-how-i-handle-secrets-in-my-work-notes.html.
This commit is contained in:
Daniel Borchmann 2024-11-16 17:17:19 +01:00
parent 5a25d5d069
commit 8521d627b4
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625

View File

@ -624,6 +624,19 @@ duplicates when elements are considered as symbols."
(or (lm-header "package-version")
(lm-header "version"))))
(defun db/auth-get-key (host key)
"Return value of KEY from auth-sources for HOST.
This is a convenience function for `auth-source-search'. Not
quite sure whether something like this exists already?"
;; Inspired by https://magnus.therning.org/2024-09-01-improving-how-i-handle-secrets-in-my-work-notes.html.
(let ((entry (-> (auth-source-search :host host)
car
(plist-get key))))
(if (eq key :secret)
(funcall entry)
entry)))
;;; Base45 Decoding