[X2Go-Commits] x2gobroker.git - build-main (branch) updated: 0.0.1.0-3-gaea8e30

X2Go dev team git-admin at x2go.org
Sun May 19 13:03:28 CEST 2013


The branch, build-main has been updated
       via  aea8e30472982caf3be18c73e3175becfc6d6b4a (commit)
      from  19582aa37e0e3cab202c43cd7497d791cbeee1b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 etc/broker/x2gobroker-sessionprofiles.conf |    1 +
 x2gobroker/defaults.py                     |    1 +
 x2gobroker/web/uccs.py                     |  205 ++++++++++++++++++++++++++++
 3 files changed, 207 insertions(+)
 create mode 100644 x2gobroker/web/uccs.py

The diff of changes is:
diff --git a/etc/broker/x2gobroker-sessionprofiles.conf b/etc/broker/x2gobroker-sessionprofiles.conf
index dc79a6b..2f0caea 100644
--- a/etc/broker/x2gobroker-sessionprofiles.conf
+++ b/etc/broker/x2gobroker-sessionprofiles.conf
@@ -59,6 +59,7 @@ dpi=96
 sshport=22
 setdpi=0
 pack=16m-jpeg
+directrdp=false
 
 ### EXAMPLES: Below you find some config examples. Adapt them to your needs or
 ### simply write your own session profiles and remove the examples below.
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index fcbb8ca..8a930dc 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -193,6 +193,7 @@ X2GOBROKER_SESSIONPROFILE_DEFAULTS = {
         u'pack': u'16m-jpeg',
         u'user': '',
         u'host': [ u'localhost', ],
+        u'directrdp': False,
         u'acl-users-allow': [],
         u'acl-users-deny': [],
         u'acl-users-order': '',
diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py
new file mode 100644
index 0000000..be63096
--- /dev/null
+++ b/x2gobroker/web/uccs.py
@@ -0,0 +1,205 @@
+#!/usr/bin/env python
+
+# This file is part of the  X2Go Project - http://www.x2go.org
+# Copyright (C) 2011-2012 by Oleksandr Shneyder <oleksandr.shneyder at obviously-nice.de>
+# Copyright (C) 2011-2012 by Heinz-Markus Graesing <heinz-m.graesing at obviously-nice.de>
+# Copyright (C) 2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+#
+# X2Go Session Broker is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# X2Go Session Broker is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# modules
+import types
+import tornado.web
+from tornado.escape import native_str, parse_qs_bytes
+
+# Python X2Go Broker modules
+import x2gobroker.defaults
+
+from x2gobroker.loggers import logger_broker, logger_error
+
+
+def convert_to_builtin_type(obj):
+    d = { }
+    d.update(obj.__dict__)
+    return d
+
+
+class ManagementServer():
+    def __init__(self, url, name):
+        self.RemoteDesktopServers = []
+        self.AdditionalManagementServers = []
+        self.URL = url
+        self.Name = name
+
+    def set_default(self, tsName):
+        if isinstance(tsName, str):
+            self.DefaultServer = tsName
+        else:
+            raise TypeError("set_default expects a string argument")
+
+    def add_terminal_server(self, server):
+        self.RemoteDesktopServers.append(server)
+
+    def add_additional_management_server(self, amserver):
+        if isinstance(amserver, AdditionalManagementServer):
+            self.AdditionalManagementServers.append(amserver)
+        else:
+            raise TypeError("add_additional_management_server expects a "\
+                "AdditionalManagementServer argument")
+
+    def toJson(self):
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+class AdditionalManagementServer():
+    def __init__(self, url, name):
+        self.URL = url
+        self.Name = name
+
+
+class RDPServer():
+    def __init__(self, url, name, username=None, password=None):
+        self.URL = url
+        self.Name = name
+        self.Protocol = 'freerdp'
+        self.DomainRequired = True
+        self.Username = username
+        self.Password = password
+
+    def add_domain(self, domainName):
+        if isinstance(domainName, str):
+            self.WindowsDomain = domainName
+        else:
+            raise TypeError("add_domain expects a string argument")
+
+    def toJson(self):
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+class X2GoServer():
+    def __init__(self, url, name, username=None, password=None):
+        self.URL = url
+        self.Name = name
+        self.Protocol = 'x2go'
+        self.SessionTypeRequired = True
+        self.Username = username
+        self.Password = password
+
+    def add_sessiontype(self, sessiontypeName):
+        if isinstance(domainName, str):
+            self.SessionType = sessiontypeName
+        else:
+            raise TypeError("add_sessiontype expects a string argument")
+
+    def toJson(self):
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+class X2GoBrokerWeb(tornado.web.RequestHandler):
+
+    http_header_items = {
+        'Content-Type': 'text/plain; charset=utf-8',
+        'Expires': '+1h',
+    }
+
+    def _gen_http_header(self):
+
+        for http_header_item in self.http_header_items.keys():
+            self.set_header(http_header_item, self.http_header_items[http_header_item])
+
+    def get(self, backend):
+        if x2gobroker.defaults.X2GOBROKER_DEBUG:
+            self._gen_http_header()
+            logger_broker.warn('GET http request detected, if unwanted: disable X2GOBROKER_DEBUG')
+            return self.post(backend)
+        raise tornado.web.HTTPError(404)
+
+    def post(self, backend):
+
+        if not backend:
+            backend = x2gobroker.defaults.X2GOBROKER_DEFAULT_BACKEND
+        else:
+            backend = backend.rstrip('/')
+
+        # silence pyflakes...
+        broker_backend = None
+        # dynamically detect broker backend from given URL
+        exec("import x2gobroker.brokers.{backend}_broker".format(backend=backend))
+        exec("broker_backend = x2gobroker.brokers.{backend}_broker.X2GoBroker()".format(backend=backend))
+        global_config = broker_backend.get_global_config()
+
+        # if the broker backend is disabled in the configuration, pretend to have nothing on offer
+        if not broker_backend.is_enabled():
+            raise tornado.web.HTTPError(404)
+
+        # FIXME: this is to work around a bug in X2Go Client (http://bugs.x2go.org/138)
+        content_type = self.request.headers.get("Content-Type", "")
+        if not content_type.startswith("application/x-www-form-urlencoded"):
+            for name, values in parse_qs_bytes(native_str(self.request.body)).iteritems():
+                self.request.arguments.setdefault(name, []).extend(values)
+
+        # set the client address for the broker backend
+        ip = self.request.remote_ip
+        if ip:
+            logger_broker.info('client address is {address}'.format(address=ip))
+            broker_backend.set_client_address(ip)
+        elif not x2gobroker.defaults.X2GOBROKER_DEBUG:
+            # if the client IP is not set, we pretend to have nothing on offer
+            logger_error.error('client could not provide an IP address, pretending: 404 Not Found')
+            raise tornado.web.HTTPError(404)
+
+        #username = self.get_argument('user', default='')
+        #password = self.get_argument('password', default='')
+        #cookie = self.get_argument('cookie', default='')
+        #task = self.get_argument('task', default='')
+        #profile_id = self.get_argument('sid', default='')
+        #new_password = self.get_argument('newpass', default='')
+
+        output = ''
+
+        #logger_broker.debug ('username: {username}, password: {password}, task: {task}, profile_id: {profile_id}'.format(username=username, password='XXXXX', task=task, profile_id=profile_id))
+        #if broker_backend.check_access(username=username, password=password, cookie=cookie):
+
+        ###
+        ### CONFIRM SUCCESSFUL AUTHENTICATION FIRST
+        ###
+
+        profiles = broker_backend.list_profiles(username)
+        if profiles:
+            ms = ManagementServer('http://localhost:8080/uccs/{backend}'.format(backend=backend), 'X2Go Session Broker')
+
+            profile_ids = profiles.keys()
+            profile_ids.sort()
+
+            for profile_id in profile_ids:
+
+                if profiles[profile_id]['directrdp']:
+                    pass
+                else:
+                    ts = X2GoServer(
+                            url='{hostname}:{port}'.format(hostname=profiles[profile_id]['host'], port=profiles[profile_id]['sshport'])
+                            name=profiles[profile_id]['name']
+                            username=profiles[profile_id]['user']
+                    )
+                ms.add_terminal(ts)
+
+            output += ms.toJson()
+
+            self.write(output)
+            return
+
+        raise tornado.web.HTTPError(401)
+


hooks/post-receive
-- 
x2gobroker.git (HTTP(S) Session broker for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).




More information about the x2go-commits mailing list