[X2Go-Commits] [python-x2go] 01/01: Handle broker setups that don't require credentials. Connection can be established simply by leaving the password (and authid) empty.
git-admin at x2go.org
git-admin at x2go.org
Sat Apr 5 09:02:14 CEST 2014
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository python-x2go.
commit 7686e68b58b310c847e88781ef050ceb8f23335b
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Sat Apr 5 09:02:09 2014 +0200
Handle broker setups that don't require credentials. Connection can be established simply by leaving the password (and authid) empty.
---
debian/changelog | 2 ++
x2go/backends/profiles/httpbroker.py | 31 ++++++++++++++++---------------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 191781c..7b4b6c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,8 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low
- Capture broker connection problems during selectsession calls to the
broker via a HOOK method.
- Allow user interaction via a HOOK if broker connection problems occur.
+ - Handle broker setups that don't require credentials. Connection can
+ be established simply by leaving the password (and authid) empty.
* debian/control:
+ Add dependencies: python-requests, python-simplejson.
* python-x2go.spec:
diff --git a/x2go/backends/profiles/httpbroker.py b/x2go/backends/profiles/httpbroker.py
index a89edd8..703e6fa 100644
--- a/x2go/backends/profiles/httpbroker.py
+++ b/x2go/backends/profiles/httpbroker.py
@@ -52,7 +52,6 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
broker_url="http://localhost:8080/json/",
broker_username=None,
broker_password=None,
- broker_noauth=False,
logger=None, loglevel=log.loglevel_DEFAULT,
**kwargs):
"""\
@@ -65,8 +64,6 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
@param broker_password: use this password for authentication against the X2Go Session Broker (avoid
password string in the C{broker_URL} parameter is highly recommended)
@type broker_password: C{str}
- @param broker_noauth: the X2Go Session Broker accepts connections without authentication
- @type broker_noauth: C{bool}
@param logger: you can pass an L{X2GoLogger} object to the
L{X2GoSessionProfilesHTTPSBROKER} constructor
@type logger: L{X2GoLogger} instance
@@ -75,7 +72,6 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
@type loglevel: C{int}
"""
- self.broker_noauth = broker_noauth
if broker_url.upper() != "HTTP":
match = re.match('^(?P<protocol>(http(|s)))://(|(?P<user>[a-zA-Z0-9_\.-]+)(|:(?P<password>.*))@)(?P<hostname>[a-zA-Z0-9\.-]+)(|:(?P<port>[0-9]+))($|/(?P<path>.*)$)', broker_url)
p = match.groupdict()
@@ -83,11 +79,10 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
self.broker_username = p['user']
else:
self.broker_username = broker_username
- if not self.broker_noauth:
- if p['password']:
- self.broker_password = p['password']
- else:
- self.broker_password = broker_password
+ if p['password']:
+ self.broker_password = p['password']
+ elif broker_password:
+ self.broker_password = broker_password
else:
self.broker_password = None
@@ -103,10 +98,7 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
self.broker_password = broker_password
self.broker_url = broker_url
- base.X2GoSessionProfiles.__init__(self, session_profile_defaults=session_profile_defaults, logger=logger, loglevel=loglevel)
- if self.broker_url != "HTTP":
- self.logger("Using session broker at URL: %s" % self.broker_url, log.loglevel_NOTICE)
-
+ self.broker_noauth = False
self.broker_authid = None
self._broker_profile_cache = {}
self._mutable_profile_ids = None
@@ -114,6 +106,10 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
self._broker_type = "http"
+ base.X2GoSessionProfiles.__init__(self, session_profile_defaults=session_profile_defaults, logger=logger, loglevel=loglevel)
+ if self.broker_url != "HTTP":
+ self.logger("Using session broker at URL: %s" % self.broker_url, log.loglevel_NOTICE)
+
# for broker based autologin, we have to be able to provide public/private key pair
self.broker_my_pubkey, self.broker_my_privkey = genkeypair(local_username=_CURRENT_LOCAL_USER, client_address='127.0.0.1')
@@ -153,11 +149,14 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
raise x2go.x2go_exceptions.X2GoBrokerConnectionException('Failed to connect to URL %s' % self.broker_url)
if r.status_code == 200:
payload = json.loads(r.text)
- if payload.has_key('next-authid'):
+ if not self.broker_authid and not self.broker_password:
+ self.broker_noauth = True
+ elif payload.has_key('next-authid'):
self.broker_authid = payload['next-authid']
self.broker_username = broker_username or ''
self.broker_password = broker_password or ''
self._broker_auth_successful = True
+ self.populate_session_profiles()
return True
self._broker_auth_successful = False
self.broker_authid = None
@@ -180,6 +179,7 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
self._broker_auth_successful = False
self.broker_authid = None
self.broker_password = None
+ self.broker_noauth = False
def is_broker_authenticated(self):
if self._broker_auth_successful is None:
@@ -271,7 +271,8 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
@rtype: C{dict}
"""
- if self.broker_noauth or \
+ if self.is_broker_authenticated() and \
+ self.broker_noauth or \
self.broker_username and self.broker_password:
session_profiles = self.broker_listprofiles()
--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
More information about the x2go-commits
mailing list