diff options
author | tv <tv@nomic.retiolum> | 2013-01-24 23:40:05 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-01-24 23:40:05 +0100 |
commit | 245a815267928096ea18d9d49cd395b87a7af175 (patch) | |
tree | 1aaba258abf30eafec4dd29b84edd7c1a5d4e842 /services/checkers.py | |
parent | 17ad911ae984843d467f8492b0644227715f203a (diff) |
services: minimal services.txt-over-ssh provider (twisted)
Diffstat (limited to 'services/checkers.py')
-rw-r--r-- | services/checkers.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/services/checkers.py b/services/checkers.py new file mode 100644 index 00000000..dbfe1323 --- /dev/null +++ b/services/checkers.py @@ -0,0 +1,25 @@ + +import base64, binascii +from twisted.python.filepath import FilePath +from twisted.conch.checkers import SSHPublicKeyDatabase + + +class PublicKeyChecker(SSHPublicKeyDatabase): + + def __init__(self, filename): + self.filepath = FilePath(filename) + + def getAuthorizedKeysFiles(self, credentials): + return [self.filepath] + + def checkKey(self, credentials): + for line in self.filepath.open(): + parts = line.split() + if len(parts) < 2: + continue + try: + if base64.decodestring(parts[1]) == credentials.blob: + return True + except binascii.Error: + continue + return False |