Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed May 9, 2019
2 parents be9823b + ff3fdd1 commit c1edd78
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ mox3
nose
jwcrypto;python_version>="2.7"
enum34;python_version=="3.3"
redis;python_version>="2.7"
simplejson;python_version>="2.7"
2 changes: 1 addition & 1 deletion websockify/auth_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def authenticate(self, headers, target_host, target_port):
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."""

Expand Down
20 changes: 20 additions & 0 deletions websockify/token_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,23 @@ def lookup(self, token):
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(':')

0 comments on commit c1edd78

Please sign in to comment.