unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Enable passwords to be functions in erc-services
@ 2020-03-20 21:49 Rudolf Adrian Kral
  2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
  0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Adrian Kral @ 2020-03-20 21:49 UTC (permalink / raw)
  To: GNU Emacs Developers

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

Hi,

I have written a patch enabling use of functions for providing passwords
in erc-services.el. My intuition is to avoid passwords being stored in
plaintext and use something like auth-sources instead. What do you
think?

Best regards,
Rudolf Kral


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for erc-services --]
[-- Type: text/x-diff, Size: 2118 bytes --]

diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index 2d1d8556b2..d61e5f0db3 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -47,6 +47,12 @@
 ;;
 ;; (setq erc-nickserv-passwords '((freenode (("nickname" "password")))))
 ;;
+;; You can also provide a function as a password. ERC will evaluate it when
+;; needed for making a connection.
+;;
+;; (setq erc-nickserv-passwords '((freenode
+;;                                 (("nickname" (lambda () "password"))))))
+;;
 ;; The default automatic identification mode is autodetection of NickServ
 ;; identify requests.  Set the variable `erc-nickserv-identify-mode' if
 ;; you'd like to change this behavior.  You can also change the way
@@ -174,7 +180,7 @@ erc-nickserv-passwords
 Example of use:
   (setq erc-nickserv-passwords
         \\='((freenode ((\"nick-one\" . \"password\")
-                     (\"nick-two\" . \"password\")))
+                     (\"nick-two\" . (lambda () \"password\"))))
           (DALnet ((\"nick\" . \"password\")))))"
   :group 'erc-services
   :type '(repeat
@@ -198,8 +204,9 @@ erc-nickserv-passwords
 		(repeat :tag "Nickname and password"
 			(cons :tag "Identity"
 			      (string :tag "Nick")
-			      (string :tag "Password"
-                                      :secret ?*))))))
+                              (choice :tag "Password"
+                                      (string :secret ?*)
+                                      (function)))))))
 
 ;; Variables:
 
@@ -415,9 +422,12 @@ erc-nickserv-call-identify-function
       (call-interactively 'erc-nickserv-identify)
     (when erc-nickserv-passwords
       (erc-nickserv-identify
-       (cdr (assoc nickname
-		   (nth 1 (assoc (erc-network)
-				 erc-nickserv-passwords))))))))
+       (let ((raw-password (cdr (assoc nickname
+                                       (nth 1 (assoc (erc-network)
+                                                     erc-nickserv-passwords))))))
+         (if (functionp raw-password)
+             (funcall raw-password)
+           raw-password))))))
 
 (defvar erc-auto-discard-away)
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Enable passwords to be functions in erc-services
  2020-03-20 21:49 [PATCH] Enable passwords to be functions in erc-services Rudolf Adrian Kral
@ 2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
  2020-04-09  4:21   ` Amin Bandali
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Félix Rezende Ribeiro @ 2020-04-08 14:21 UTC (permalink / raw)
  To: Rudolf Adrian Kral; +Cc: GNU Emacs Developers

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

Hello Rudolf,

Rudolf Adrian Kral <adriankral@gmail.com> writes:

> I have written a patch enabling use of functions for providing passwords
> in erc-services.el. My intuition is to avoid passwords being stored in
> plaintext and use something like auth-sources instead. What do you
> think?

I think that’s a nice addition.  How hard is to setup it to use
auth-source?

-- 
Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF]
<http://oitofelix.freeshell.org/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Enable passwords to be functions in erc-services
  2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
@ 2020-04-09  4:21   ` Amin Bandali
  2020-06-11 19:21     ` Ted Zlatanov
  0 siblings, 1 reply; 4+ messages in thread
From: Amin Bandali @ 2020-04-09  4:21 UTC (permalink / raw)
  To: Bruno Félix Rezende Ribeiro; +Cc: Rudolf Adrian Kral, GNU Emacs Developers

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

Hello,

Thanks for the patch, Rudolf.

Bruno Félix Rezende Ribeiro <oitofelix@gnu.org> writes:

> Hello Rudolf,
>
> Rudolf Adrian Kral <adriankral@gmail.com> writes:
>
>> I have written a patch enabling use of functions for providing passwords
>> in erc-services.el. My intuition is to avoid passwords being stored in
>> plaintext and use something like auth-sources instead. What do you
>> think?
>
> I think that’s a nice addition.  How hard is to setup it to use
> auth-source?

+1.  Rudolf, what do you think about sending a new version with examples
using the auth-source library, and maybe even the newer auth-source-pass
as well?

Also, have you filled out and submitted a copy of the copyright
assignment form for your changes to GNU Emacs yet?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Enable passwords to be functions in erc-services
  2020-04-09  4:21   ` Amin Bandali
@ 2020-06-11 19:21     ` Ted Zlatanov
  0 siblings, 0 replies; 4+ messages in thread
From: Ted Zlatanov @ 2020-06-11 19:21 UTC (permalink / raw)
  To: Bruno Félix Rezende Ribeiro; +Cc: Rudolf Adrian Kral, GNU Emacs Developers

On Thu, 09 Apr 2020 00:21:50 -0400 Amin Bandali <bandali@gnu.org> wrote: 

AB> +1.  Rudolf, what do you think about sending a new version with examples
AB> using the auth-source library, and maybe even the newer auth-source-pass
AB> as well?

erc.el uses auth-source.el so I agree this makes sense to add to
erc-services.el. Compared to Rudolf's proposed patch, I think this will
have the advantage of less code and easier integration for the user.

Maybe something like this (in the authinfo+.json format) would work for
the users?

machine MyService login myuser password mysecret
machine freenode login user1 password secret1
machine freenode login user2 password secret2

[
 { "machine": "MyService", "login": "myuser", "password": "mysecret" },
 { "machine": "freenode", "login": "user1", "password": "secret1" },
 { "machine": "freenode", "login": "user2", "password": "secret2" }
]

so then you'd just call:

(auth-source-search :host "MyService" :user "myuser")

auth-source-pass.el provides a backend for auth-source.el, so it will be
usable like all the other storage backends (.gpg files, plain files,
JSON files, Secrets API, etc). I don't think any extra work will be
required on the ERC side or the user side.

Ted



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-11 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 21:49 [PATCH] Enable passwords to be functions in erc-services Rudolf Adrian Kral
2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
2020-04-09  4:21   ` Amin Bandali
2020-06-11 19:21     ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).