summaryrefslogtreecommitdiff
path: root/login.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-02-23 21:08:36 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-02-23 21:08:36 +0100
commit7a7cce4fae7d530e14d7e107555b3fa113609e73 (patch)
treef2a65e8e81c0a8223dad9415f447cb5b4e05d5a7 /login.py
parent19f5595b2532379c3ec30e4ef02b694f5693b8b1 (diff)
Use ~/.fot.users to authenticate users.
Diffstat (limited to 'login.py')
-rw-r--r--login.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/login.py b/login.py
index 869f678..6c95e56 100644
--- a/login.py
+++ b/login.py
@@ -1,7 +1,11 @@
from twisted.cred import portal, checkers
from twisted.conch import manhole, manhole_ssh
+import hashlib
-def getManholeFactory(namespace, **passwords):
+def hash(username, netpass, localpass):
+ return hashlib.sha1(netpass).hexdigest()
+
+def getManholeFactory(namespace, filename):
def getManhole(_):
return manhole.Manhole(namespace)
@@ -9,12 +13,13 @@ def getManholeFactory(namespace, **passwords):
realm.chainedProtocolFactory.protocolFactory = getManhole
p = portal.Portal(realm)
- p.registerChecker(checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords))
+ p.registerChecker(checkers.FilePasswordDB(filename, hash = hash))
return manhole_ssh.ConchFactory(p)
if __name__ == '__main__':
from twisted.internet import reactor
- factory = getManholeFactory({'x': 'foo'}, user = 'pass')
+ import os
+ factory = getManholeFactory({'x': 'foo'}, os.path.expanduser('~/.fot.users'))
reactor.listenTCP(5022, factory)
reactor.run()