summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-21 12:43:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-03-21 12:43:57 -0700
commit90d7449c02681e1e16d81784d6610d6b0af96a3d (patch)
tree814a7c66b84912c8d131626c36cd5a5346334516
parent610e83f3d6654d2fe95c20cf2280f7d894ac58f8 (diff)
downloadtamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.tar.gz
tamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.tar.bz2
tamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.zip
Implementing IMAP authentication.
-rw-r--r--auth.txr31
-rw-r--r--config.txr1
2 files changed, 31 insertions, 1 deletions
diff --git a/auth.txr b/auth.txr
index bb8f4cf..e2b9c26 100644
--- a/auth.txr
+++ b/auth.txr
@@ -15,5 +15,34 @@
(let ((response (get-string sock)))
(equal [response 2..4] "OK")))))
@(define auth (userid password))
-@ (require (sasl-auth userid password))
+@ (if (eq auth :sasl))
+@ (require (sasl-auth userid password))
+@ (elif (eq auth :imap))
+@ (try)
+@ (bind s @(let ((sock (open-socket af-inet sock-stream "r+ib")))
+ (sock-connect sock (new sockaddr-in
+ addr inaddr-loopback
+ port 143))
+ (sock-recv-timeout sock (* 30 1000000))))
+@ (next s)
+* OK@(skip)
+@ (output s)
+A0001 LOGIN @userid @password@\r
+@ (end)
+@ (repeat :gap 0)
+* @(skip)
+@ (end)
+@ (cases)
+A0001 OK@(skip)
+@ (accept)
+@ (or)
+A0001 NO@(skip)
+@ (fail)
+@ (end)
+@ (catch timeout-error)
+@ (fail)
+@ (end)
+@ (else)
+@ (fail)
+@ (end)
@(end)
diff --git a/config.txr b/config.txr
index 4f28b53..74315ba 100644
--- a/config.txr
+++ b/config.txr
@@ -1,5 +1,6 @@
@(bind debug-enable t)
@(bind aliases-file "/etc/tamarind/aliases")
@(bind sessions-dir "/var/run/tamarind/sessions")
+@(bind auth :imap)
@(bind sasl-sock "/var/run/saslauthd/mux")
@(bind csslink "")