File PyJWT-token-plugin.patch of Package python-websockify
From cf2bd3930d8506dbb4db172c89a6a628134595aa Mon Sep 17 00:00:00 2001
From: UXabre <arend.lapere@gmail.com>
Date: Fri, 21 Dec 2018 03:21:29 -0500
Subject: [PATCH] Added JWT tokens capability
Index: websockify-0.8.0/websockify/token_plugins.py
===================================================================
--- websockify-0.8.0.orig/websockify/token_plugins.py
+++ websockify-0.8.0/websockify/token_plugins.py
@@ -125,5 +125,17 @@ class JWTTokenApi(BasePlugin):
print >>sys.stderr, "Failed to parse token: %s" % (e)
return None
except ImportError as e:
- print >>sys.stderr, "package jwcrypto not found, are you sure you've installed it correctly?"
+ try:
+ import jwt
+
+ secret = open(self.source, 'rb').read()
+ parsed = jwt.decode(token, secret, algorithms=['RS256', 'RS384', 'RS512', 'HS256', 'HS384', 'HS512', 'ES256', 'ES384', 'ES512', 'PS256', 'PS384', 'PS512'])
+
+ return (parsed['host'], parsed['port'])
+ except Exception as e:
+ print >>sys.stderr, "Failed to parse token: %s" % (e)
+ return None
+ except ImportError:
+ print >>sys.stderr, "neither package jwcrypto nor PyJWT found, are you sure you've installed one of them correctly?"
+ return None
return None