[X2Go-Commits] [x2gobroker] 01/01: Implement dynamic authid for JSON WebUI frontend. Add a generic metadata top level to the JSON output tree.

git-admin at x2go.org git-admin at x2go.org
Fri Mar 7 22:37:55 CET 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gobroker.

commit 5976792eaecdb1d61fefb9248e633482a4fa12d8
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Fri Mar 7 22:37:30 2014 +0100

    Implement dynamic authid for JSON WebUI frontend. Add a generic metadata top level to the JSON output tree.
---
 debian/changelog       |    2 ++
 x2gobroker/web/json.py |   28 ++++++++++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 49e1087..dcdce07 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -91,6 +91,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low
     - Add --drop-privileges feature so that x2gobroker-daemon can drop root
       privileges when started via systemd. Only drop privileges if
       x2gobroker(-daemon) is run as uidNumber 0.
+    - Implement dynamic authid for JSON WebUI frontend. Add a generic metadata
+      top level to the JSON output tree.
   * debian/control:
     + Replace LDAP support with session brokerage support in LONG_DESCRIPTION.
     + Fix SYNOPSIS texts.
diff --git a/x2gobroker/web/json.py b/x2gobroker/web/json.py
index 1f10b31..9574796 100644
--- a/x2gobroker/web/json.py
+++ b/x2gobroker/web/json.py
@@ -116,7 +116,9 @@ class X2GoBrokerWeb(_RequestHandler):
         profile_id = self.get_argument('sid', default='')
         new_password = self.get_argument('newpass', default='')
 
-        output = ''
+        payload = {
+            'task': task,
+        }
 
         logger_broker.debug ('username: {username}, password: {password}, task: {task}, profile_id: {profile_id}, cookie: {cookie}'.format(username=username, password='XXXXX', task=task, profile_id=profile_id, cookie=cookie))
         access, next_cookie = broker_backend.check_access(username=username, password=password, ip=ip, cookie=cookie)
@@ -125,8 +127,14 @@ class X2GoBrokerWeb(_RequestHandler):
             ###
             ### CONFIRM SUCCESSFUL AUTHENTICATION FIRST
             ###
+            payload.update({
+                'auth_status': 'Access granted',
+            })
 
-            ### FIXME: find good way to pass next cookie to client - stored in next_cookie
+            if next_cookie is not None:
+                payload.update({
+                    'authid': next_cookie,
+                })
 
             ###
             ### X2GO BROKER TASKS
@@ -143,13 +151,19 @@ class X2GoBrokerWeb(_RequestHandler):
                 #self.write(broker_backend.test_connection())
                 return
 
-            if task == 'listsessions':
+            # listsessions is old style, listprofiles semantically more correct
+            if task == 'listsessions' or task == 'listprofiles':
 
-                profiles = broker_backend.list_profiles(username)
-                output += json.dumps(profiles, indent=4, sort_keys=True)
+                payload.update({
+                    'profiles': broker_backend.list_profiles(username),
+                })
+                output += json.dumps(payload, indent=4, sort_keys=True)
 
             elif task == 'selectsession':
 
+                payload.update({
+                    'selected_session': {}
+                })
                 if profile_id:
 
                     selected_session = {}
@@ -167,7 +181,9 @@ class X2GoBrokerWeb(_RequestHandler):
                         if profile_info.has_key('session_info'):
                             selected_session['session_info'] = profile_info['session_info']
 
-                        output += json.dumps(selected_session, indent=4, sort_keys=True)
+                        payload['selected_session'] = selected_session
+
+                output += json.dumps(payload, indent=4, sort_keys=True)
 
             self.write(output)
             return

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git



More information about the x2go-commits mailing list