Browse Source

implement authentication to Murmur using the Ice secret.

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

10
pyweb/mumble/MumbleCtlIce.py

@ -49,9 +49,15 @@ def protectDjangoErrPage( func ):
@protectDjangoErrPage @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 """ Choose the correct Ice handler to use (1.1.8 or 1.2.x), and make sure the
Murmur version matches the slice Version. 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: try:
@ -75,6 +81,8 @@ def MumbleCtlIce( connstring, slicefile ):
import Murmur import Murmur
ice = Ice.initialize() ice = Ice.initialize()
if icesecret:
ice.getImplicitContext().put("secret", icesecret)
prx = ice.stringToProxy( connstring.encode("utf-8") ) prx = ice.stringToProxy( connstring.encode("utf-8") )
meta = Murmur.MetaPrx.checkedCast(prx) meta = Murmur.MetaPrx.checkedCast(prx)

2
pyweb/mumble/forms.py

@ -107,7 +107,7 @@ class MumbleForm( PropertyModelForm ):
class Meta: class Meta:
model = Mumble; model = Mumble;
exclude = ( 'dbus', 'addr', 'port', );
exclude = ( 'dbus', 'addr', 'port', 'secret' );
class MumbleAdminForm( MumbleForm ): class MumbleAdminForm( MumbleForm ):

14
pyweb/mumble/mctl.py

@ -98,8 +98,16 @@ class MumbleCtlBase (object):
raise NotImplementedError( "mctl::verifyPassword" ); raise NotImplementedError( "mctl::verifyPassword" );
@staticmethod @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 # check cache
if connstring in MumbleCtlBase.cache: if connstring in MumbleCtlBase.cache:
@ -115,7 +123,7 @@ class MumbleCtlBase (object):
ctl = MumbleCtlDbus( connstring ) ctl = MumbleCtlDbus( connstring )
else: else:
from MumbleCtlIce import MumbleCtlIce from MumbleCtlIce import MumbleCtlIce
ctl = MumbleCtlIce( connstring, slicefile )
ctl = MumbleCtlIce( connstring, slicefile, icesecret )
MumbleCtlBase.cache[connstring] = ctl; MumbleCtlBase.cache[connstring] = ctl;
return 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. Only one instance will be created, and reused on subsequent calls.
""" """
if not self._ctl: 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; return self._ctl;
ctl = property( getCtl, doc="Get a Control object for this server. The ctl is cached for later reuse." ); ctl = property( getCtl, doc="Get a Control object for this server. The ctl is cached for later reuse." );

Loading…
Cancel
Save