summaryrefslogtreecommitdiff
path: root/src/wasp-auth.el
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-11-26 03:23:31 -0500
committerLLLL Colonq <llll@colonq>2024-11-26 03:23:31 -0500
commit0b95071fe628d91238549b062961e724088d3b8b (patch)
treeb4cf3ae960e0b52ed014ab4ba423fda1075e5d60 /src/wasp-auth.el
parent6e3c47b1ad746f0891592a97cc6ffb6e0280adbb (diff)
Update :4
Diffstat (limited to 'src/wasp-auth.el')
-rw-r--r--src/wasp-auth.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/wasp-auth.el b/src/wasp-auth.el
new file mode 100644
index 00000000..06098d31
--- /dev/null
+++ b/src/wasp-auth.el
@@ -0,0 +1,37 @@
+;;; wasp-auth --- SSH-based authentication -*- lexical-binding: t; -*-
+;;; Commentary:
+;;; Code:
+
+(require 'f)
+
+(defcustom w/auth-sign-process "wasp-auth-sign"
+ "Name of process for signing messages."
+ :type '(string)
+ :group 'wasp)
+
+(defcustom w/auth-error-buffer " *wasp-auth-error*"
+ "Name of buffer used to store authentication errors."
+ :type '(string)
+ :group 'wasp)
+
+(defun w/auth-sign (msg k)
+ "Sign MSG using ~/.ssh/id_ed25519 and pass the signature to K."
+ (let* ((buf (generate-new-buffer " *wasp-auth-sign*"))
+ (proc
+ (make-process
+ :name w/auth-sign-process
+ :buffer buf
+ :stderr (get-buffer-create w/auth-error-buffer)
+ :command
+ `("ssh-keygen" "-Y" "sign" "-f" ,(f-canonical "~/.ssh/id_ed25519") "-n" "file" "-")
+ :sentinel
+ (lambda (_ _)
+ (let ((sig (with-current-buffer buf (buffer-string))))
+ (kill-buffer buf)
+ (funcall k sig))))))
+ (process-send-string proc msg)
+ (process-send-string proc "\n")
+ (process-send-eof proc)))
+
+(provide 'wasp-auth)
+;;; wasp-auth.el ends here