From 83a38d960d34bc347bfc82d0dea9592204f8c4cb Mon Sep 17 00:00:00 2001 From: Luca Capacci Date: Mon, 28 Sep 2015 12:08:26 +0200 Subject: [PATCH] Added django authentication plugin --- websockify/django_auth_plugins.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/websockify/django_auth_plugins.py b/websockify/django_auth_plugins.py index fb475a2..d3536c2 100644 --- a/websockify/django_auth_plugins.py +++ b/websockify/django_auth_plugins.py @@ -1,3 +1,15 @@ +''' +Django authentication plugins for Python WebSocket library. +Copyright 2015 Luca Capacci +Licensed under LGPL version 3 + +- SessionIdAuth grants access to the target only to the users authenticated in a django web app. + +- SessionIdAuthAndHostPort determines the target based on the authenticated user. Edit get_host_port(current_user) to determine a target and a host for each user. + +''' + + from auth_plugins import AuthenticationError @@ -39,8 +51,8 @@ class SessionIdAuthAndHostPort(object): def get_host_port(current_user): - host_port_dict = {'pippo': ('localhost', 5900), - 'luca': ('localhost', 9001)} + host_port_dict = {'john': ('localhost', 5900), + 'bob': ('localhost', 5901)} if current_user.username in host_port_dict: return host_port_dict[current_user.username]