aboutsummaryrefslogtreecommitdiff
path: root/okupy
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-08-25 10:31:50 +0200
committerMichał Górny <mgorny@gentoo.org>2013-08-25 22:45:28 +0200
commitbe94c805b7b7fe0da9203e14ae08ed7e74872e38 (patch)
treef0f1b0d9923bf26e6464b91fcbd6f39bf6a0a385 /okupy
parentSupport authentication using SSH. (diff)
downloadidentity.gentoo.org-be94c805b7b7fe0da9203e14ae08ed7e74872e38.tar.gz
identity.gentoo.org-be94c805b7b7fe0da9203e14ae08ed7e74872e38.tar.bz2
identity.gentoo.org-be94c805b7b7fe0da9203e14ae08ed7e74872e38.zip
Store SSH handler list in settings.
Diffstat (limited to 'okupy')
-rw-r--r--okupy/accounts/ssh.py6
-rw-r--r--okupy/common/ssh.py11
-rw-r--r--okupy/wsgi.py2
3 files changed, 11 insertions, 8 deletions
diff --git a/okupy/accounts/ssh.py b/okupy/accounts/ssh.py
index 37ec5c1..4e5028e 100644
--- a/okupy/accounts/ssh.py
+++ b/okupy/accounts/ssh.py
@@ -2,6 +2,7 @@
from django.contrib.auth import authenticate, login
+from ..common.ssh import ssh_handler
from ..common.test_helpers import set_request
from ..crypto.ciphers import sessionrefcipher
from ..otp import init_otp
@@ -10,11 +11,6 @@ from ..otp import init_otp
ssh_handlers = {}
-def ssh_handler(f):
- ssh_handlers[f.__name__] = f
- return f
-
-
@ssh_handler
def auth(session_id, key):
try:
diff --git a/okupy/common/ssh.py b/okupy/common/ssh.py
index 830f840..5969b19 100644
--- a/okupy/common/ssh.py
+++ b/okupy/common/ssh.py
@@ -11,12 +11,17 @@ import inspect
import socket
import threading
-from ..accounts.ssh import ssh_handlers
-
LISTEN_BACKLOG = 20
+def ssh_handler(f):
+ if not hasattr(settings, 'SSH_HANDLERS'):
+ settings.SSH_HANDLERS = {}
+ settings.SSH_HANDLERS[f.__name__] = f
+ return f
+
+
class SSHServer(paramiko.ServerInterface):
def __init__(self):
paramiko.ServerInterface.__init__(self)
@@ -35,7 +40,7 @@ class SSHServer(paramiko.ServerInterface):
args = spl[1:]
try:
- h = ssh_handlers[cmd]
+ h = settings.SSH_HANDLERS[cmd]
# this is an easy way of checking if we have correct args
inspect.getcallargs(h, *args, key=key)
except (KeyError, TypeError) as e:
diff --git a/okupy/wsgi.py b/okupy/wsgi.py
index de75c8f..e2c657e 100644
--- a/okupy/wsgi.py
+++ b/okupy/wsgi.py
@@ -44,6 +44,8 @@ else:
from uwsgidecorators import postfork, thread, timer
from django.utils import autoreload
+ # autodiscover SSH handlers
+ import okupy.accounts.ssh
from okupy.common.ssh import ssh_main
import Crypto.Random