From 8f05e984c7dc19544459709092e418f3fa2a0a9b Mon Sep 17 00:00:00 2001 From: Luca Capacci Date: Mon, 28 Sep 2015 12:53:03 +0200 Subject: [PATCH] Added django authentication plugin --- websockify/django_auth_plugins.py | 61 +++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/websockify/django_auth_plugins.py b/websockify/django_auth_plugins.py index d3536c2..04e8ab5 100644 --- a/websockify/django_auth_plugins.py +++ b/websockify/django_auth_plugins.py @@ -3,9 +3,64 @@ 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. + +**************************************** SessionIdAuth **************************************** + + SessionIdAuth grants access to the target only to the users authenticated in a django web app. + + Usage: put the websockify folder inside the django project, as shown below: + + django_project + |__________django_project + | |__________ settings.py + | | + | |__________ urls.py + | | + | |__________ wsgi.py + | + | + |__________ websockify + | |__________ some files... + | | + | |__________ websockify + | |_____________ django_auth_plugins.py + | + | + |__________ other files and folders... + + Right after starting the django web app, run websockify with the --auth-plugin option (Example: ./websockify/run 6080 localhost:5900 --auth-plugin="websockify.django_auth_plugins.SessionIdAuth") + + +**************************************** SessionIdAuthAndHostPort **************************************** + + SessionIdAuthAndHostPort determines the target based on the authenticated user. + + Usage: put the websockify folder inside the django project, as shown below: + + django_project + |__________django_project + | |__________ settings.py + | | + | |__________ urls.py + | | + | |__________ wsgi.py + | + | + |__________ websockify + | |__________ some files... + | | + | |__________ websockify + | |_____________ django_auth_plugins.py + | + | + |__________ other files and folders... + + + Edit get_host_port(current_user) to implement an algorithm to determine a target and a host for each user. + + Right after starting the django web app, run websockify with the --auth-plugin and the --auth-host-port options (Example: ./websockify/run 6080 --auth-plugin="websockify.django_auth_plugins.SessionIdAuthAndHostPort" --auth-host-port) + + For a complete example: https://github.com/lucacapacci/noVncDjangoPoC '''