Browse Source

implement authentication to Murmur using the Ice secret.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
b741e01d88
  1. 16
      pyweb/mumble/MumbleCtlIce.py
  2. 2
      pyweb/mumble/forms.py
  3. 14
      pyweb/mumble/mctl.py
  4. 2
      pyweb/mumble/models.py

16
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]

2
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 ):

14
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;

2
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." );

Loading…
Cancel
Save