From b741e01d884ea2312e0e875d5ee1da59dd05f38a Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sat, 20 Feb 2010 12:23:33 +0100 Subject: [PATCH] implement authentication to Murmur using the Ice secret. --- pyweb/mumble/MumbleCtlIce.py | 16 ++++++++++++---- pyweb/mumble/forms.py | 2 +- pyweb/mumble/mctl.py | 14 +++++++++++--- pyweb/mumble/models.py | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index a8df6ab..4095497 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -49,9 +49,15 @@ def protectDjangoErrPage( func ): @protectDjangoErrPage -def MumbleCtlIce( connstring, slicefile ): +def MumbleCtlIce( connstring, slicefile=None, icesecret=None ): """ Choose the correct Ice handler to use (1.1.8 or 1.2.x), and make sure the Murmur version matches the slice Version. + + Optional parameters are the path to the slice file and the Ice secret + necessary to authenticate to Murmur. + + The path can be omitted only if running Murmur 1.2.3 or later, which + exports a getSlice method to retrieve the Slice from. """ try: @@ -74,9 +80,11 @@ def MumbleCtlIce( connstring, slicefile ): import Murmur - ice = Ice.initialize() - prx = ice.stringToProxy( connstring.encode("utf-8") ) - meta = Murmur.MetaPrx.checkedCast(prx) + ice = Ice.initialize() + if icesecret: + ice.getImplicitContext().put("secret", icesecret) + prx = ice.stringToProxy( connstring.encode("utf-8") ) + meta = Murmur.MetaPrx.checkedCast(prx) murmurversion = meta.getVersion()[:3] diff --git a/pyweb/mumble/forms.py b/pyweb/mumble/forms.py index a0929be..4359951 100644 --- a/pyweb/mumble/forms.py +++ b/pyweb/mumble/forms.py @@ -107,7 +107,7 @@ class MumbleForm( PropertyModelForm ): class Meta: model = Mumble; - exclude = ( 'dbus', 'addr', 'port', ); + exclude = ( 'dbus', 'addr', 'port', 'secret' ); class MumbleAdminForm( MumbleForm ): diff --git a/pyweb/mumble/mctl.py b/pyweb/mumble/mctl.py index 502aff1..5334b96 100644 --- a/pyweb/mumble/mctl.py +++ b/pyweb/mumble/mctl.py @@ -98,8 +98,16 @@ class MumbleCtlBase (object): raise NotImplementedError( "mctl::verifyPassword" ); @staticmethod - def newInstance( connstring, slicefile ): - """ Create a new CTL object for the given connstring. """ + def newInstance( connstring, slicefile=None, icesecret=None ): + """ Create a new CTL object for the given connstring. + + Optional parameters are the path to the slice file and the + Ice secret necessary to authenticate to Murmur. + + The path can be omitted only if using DBus or running Murmur + 1.2.3 or later, which exports a getSlice method to retrieve + the Slice from. + """ # check cache if connstring in MumbleCtlBase.cache: @@ -115,7 +123,7 @@ class MumbleCtlBase (object): ctl = MumbleCtlDbus( connstring ) else: from MumbleCtlIce import MumbleCtlIce - ctl = MumbleCtlIce( connstring, slicefile ) + ctl = MumbleCtlIce( connstring, slicefile, icesecret ) MumbleCtlBase.cache[connstring] = ctl; return ctl; diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 58b9954..6970420 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -175,7 +175,7 @@ class Mumble( models.Model ): Only one instance will be created, and reused on subsequent calls. """ if not self._ctl: - self._ctl = MumbleCtlBase.newInstance( self.dbus, settings.SLICE ); + self._ctl = MumbleCtlBase.newInstance( self.dbus, settings.SLICE, self.secret ); return self._ctl; ctl = property( getCtl, doc="Get a Control object for this server. The ctl is cached for later reuse." );