[X2Go-Commits] [x2gobroker] 01/03: JSON webUI: run pre and post auth scripts also via this backend.

git-admin at x2go.org git-admin at x2go.org
Mon Mar 31 22:49:54 CEST 2014


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

x2go pushed a commit to branch master
in repository x2gobroker.

commit 84fe80fa063d18085d4359901073ebc781aa7a6d
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon Mar 31 22:34:57 2014 +0200

    JSON webUI: run pre and post auth scripts also via this backend.
---
 debian/changelog       |    1 +
 x2gobroker/web/json.py |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index ee2b51d..f244175 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -116,6 +116,7 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low
     - Fully rewrite agent.py.
     - Fix broker crashes when no session status is available for certain
       session profiles.
+    - JSON webUI: run pre and post auth scripts also via this backend.
   * 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 77facf3..08cb973 100644
--- a/x2gobroker/web/json.py
+++ b/x2gobroker/web/json.py
@@ -125,10 +125,35 @@ class X2GoBrokerWeb(_RequestHandler):
             'task': task,
         }
 
+        if len(global_config['pre_auth_scripts']) != 0:
+            for script in global_config['pre_auth_scripts']:
+                try:
+                    post_auth_script=None
+                    exec("import x2gobroker.optional_scripts.{script}_script".format(script=script))
+                    exec("pre_auth_script = x2gobroker.optional_scripts.{script}_script.X2GoBrokerOptionalScript()".format(script=script))
+                    logger_broker.debug ('Calling pre-auth script {script} with username: {username}, password: {password}, task: {task}, profile_id: {profile_id}, ip: {ip}, cookie: {cookie}'.format(script=script,username=username, password='XXXXX', task=task, profile_id=profile_id, ip=ip, cookie=cookie))
+                    username, password, task, profile_id, ip, cookie = pre_auth_script.run_me(username=username, password=password, task=task, profile_id=profile_id, ip=ip, cookie=cookie)
+                    logger_broker.debug ('Pre-auth script {script} finished with username: {username}, password: {password}, task: {task}, profile_id: {profile_id}, ip: {ip}, cookie: {cookie}'.format(script=script,username=username, password='XXXXX', task=task, profile_id=profile_id, ip=ip, cookie=cookie))
+                except ImportError:
+                    logger_error.error('No such optional script \'{script}\''.format(script=script))
+
         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)
+
         if access:
 
+            if len(global_config['post_auth_scripts']) != 0:
+                for script in global_config['post_auth_scripts']:
+                    try:
+                        post_auth_script=None
+                        exec("import x2gobroker.optional_scripts.{script}_script".format(script=script))
+                        exec("post_auth_script = x2gobroker.optional_scripts.{script}_script.X2GoBrokerOptionalScript()".format(script=script))
+                        logger_broker.debug ('Calling post-auth script {script} with username: {username}, password: {password}, task: {task}, profile_id: {profile_id}, ip: {ip}, cookie: {cookie}'.format(script=script,username=username, password='XXXXX', task=task, profile_id=profile_id, ip=ip, cookie=cookie))
+                        username, password, task, profile_id, ip, cookie = post_auth_script.run_me(username=username, password=password, task=task, profile_id=profile_id, ip=ip, cookie=cookie)
+                        logger_broker.debug ('Post-auth script {script} finished with username: {username}, password: {password}, task: {task}, profile_id: {profile_id}, ip: {ip}, cookie: {cookie}'.format(script=script,username=username, password='XXXXX', task=task, profile_id=profile_id, ip=ip, cookie=cookie))
+                    except ImportError:
+                        logger_error.error('No such optional script \'{script}\''.format(script=script))
+
             ###
             ### CONFIRM SUCCESSFUL AUTHENTICATION FIRST
             ###

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



More information about the x2go-commits mailing list