summaryrefslogtreecommitdiff
path: root/websockify
diff options
context:
space:
mode:
authorPexMor <p.moravek@xlinux.cz>2019-04-04 13:53:17 +0200
committerPexMor <p.moravek@xlinux.cz>2019-04-29 20:32:04 +0200
commitff3fdd149d102bdde5497f4d57206cb2320f251c (patch)
treea235c47509ee797d763c4169c6a08ca2dc41f602 /websockify
parente4658ada2e2e179cdb8f6362dbb7c5e3ce3ff717 (diff)
downloadwebsockify-ff3fdd149d102bdde5497f4d57206cb2320f251c.tar.gz
novnc redis backed token_plyugins.py
Diffstat (limited to 'websockify')
-rw-r--r--websockify/auth_plugins.py2
-rw-r--r--websockify/token_plugins.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/websockify/auth_plugins.py b/websockify/auth_plugins.py
index ed3a169..2d636c2 100644
--- a/websockify/auth_plugins.py
+++ b/websockify/auth_plugins.py
@@ -87,7 +87,7 @@ class ExpectOrigin(object):
origin = headers.get('Origin', None)
if origin is None or origin not in self.source:
raise InvalidOriginError(expected=self.source, actual=origin)
-
+
class ClientCertCNAuth(object):
"""Verifies client by SSL certificate. Specify src as whitespace separated list of common names."""
diff --git a/websockify/token_plugins.py b/websockify/token_plugins.py
index 972907b..92aec98 100644
--- a/websockify/token_plugins.py
+++ b/websockify/token_plugins.py
@@ -134,3 +134,23 @@ class JWTTokenApi(BasePlugin):
except ImportError as e:
print("package jwcrypto not found, are you sure you've installed it correctly?", file=sys.stderr)
return None
+
+import sys
+
+if sys.version_info >= (2, 7):
+ import redis
+ import simplejson
+
+ class TokenRedis(object):
+ def __init__(self, src):
+ self._server, self._port = src.split(":")
+
+ def lookup(self, token):
+ client = redis.Redis(host=self._server,port=self._port)
+ stuff = client.get(token)
+ if stuff is None:
+ return None
+ else:
+ combo = simplejson.loads(stuff.decode("utf-8"))
+ pair = combo["host"]
+ return pair.split(':')