This commit is contained in:
Pierre Ossman 2019-05-09 15:51:45 +02:00
commit c1edd7818d
3 changed files with 23 additions and 1 deletions

View File

@ -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"

View File

@ -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."""

View File

@ -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(':')