diff --git a/config/fg42.user.el b/config/fg42.user.el index 5646e6e..a943943 100644 --- a/config/fg42.user.el +++ b/config/fg42.user.el @@ -74,7 +74,7 @@ ;; specific tools (lein in this case) in your exec-path. -;; IRC Extension configuration +;; IRC Extension configuration ------------------------------------------------ ;; Setup all the servers and channels you need ;; (setq irc-servers ;; '(("irc.freenode.net" diff --git a/lib/extensions/auth.el b/lib/extensions/auth.el new file mode 100644 index 0000000..ca73b93 --- /dev/null +++ b/lib/extensions/auth.el @@ -0,0 +1,22 @@ +;;; Auth --- Secret management extension for FG42 +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/extension) +(require 'extensions/auth/init) + +;; Dependencies ---------------------------------- +(depends-on 'rcauth-notify) + +(defun auth-doc () + "TBD" + "TBD") + +;; Extension ------------------------------------- +(extension auth + :version "2.32" + :on-initialize extensions/auth-initialize + :docs "lib/extensions/auth/readme.org") + +(provide 'extensions/auth) +;;; auth.el ends here diff --git a/lib/extensions/auth/init.el b/lib/extensions/auth/init.el new file mode 100644 index 0000000..c7f49fa --- /dev/null +++ b/lib/extensions/auth/init.el @@ -0,0 +1,44 @@ +;;; Auth --- Secret management extension for FG42 +;;; Commentary: +;;; Code: +(require 'auth-source) + +(defvar auht/sources '((:sources "~/.authinfo.gpg"))) + +(defun auth/find-credential (host) + "Find the credential for the given HOST. +Return a list of credential pairs." + (let (auth-list '()) + (dolist (cred (auth-source-search :host host + :require '(:user :secret))) + (let ((user (plist-get cred :user)) + (secret (plist-get cred :secret))) + (add-to-list 'auth-list + (list user + (if (functionp secret) + (funcall secret) + secret))))) + auth-list)) + +(defun utils/bold (text) + "Make the TEXT appears in bold form." + (propertize text 'face 'bold)) + + +(defun auth/credential-for (args host) + "Return the credential for the given HOST. +ARGS should be ignored." + (interactive "P\nsHost: ") + (dolist (pair (auth/find-credential host)) + (message (concat "User: " (utils/bold (car pair)) + " Passowrd: " (utils/bold(car (cdr pair))))))) + +(auth/credential-for nil "freenode") +(auth/find-credential "freenode") + +(defun extensions/irc-initialize () + "Initialize the Auth extension." + (setq auth-sources auth/sources)) + +(provide 'extensions/irc/init) +;;; init.el ends here diff --git a/lib/extensions/irc/init.el b/lib/extensions/irc/init.el index 717583d..d0bfdc4 100644 --- a/lib/extensions/irc/init.el +++ b/lib/extensions/irc/init.el @@ -64,9 +64,6 @@ It returns nil if no password is available." (rcirc-track-minor-mode 1) (rcirc nil)) - - - ;;;###autoload (defun extensions/irc-initialize () "Initialize the irc extention."