mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-23 22:59:30 +00:00
Various changes to several aspects of the model base.
* Added SSOUser extension profile for auth * Now checks for Corp membership and executes required commands * Various small fixups
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
|
||||
def get_api(api):
|
||||
try:
|
||||
mod = __import__(self.service.api)
|
||||
mod = __import__(api)
|
||||
except ImportError:
|
||||
raise DoesNotExist('Error creating service')
|
||||
|
||||
for i in self.service.api.spit(".")[1:]:
|
||||
for i in api.split(".")[1:]:
|
||||
mod = getattr(mod, i)
|
||||
|
||||
return getattr(mod, mod.ServiceClass)()
|
||||
@@ -33,7 +33,7 @@ class BaseService():
|
||||
""" Disable a user """
|
||||
pass
|
||||
|
||||
def enable_user(self, username):
|
||||
def enable_user(self, username, password):
|
||||
""" Enable a user """
|
||||
pass
|
||||
|
||||
|
||||
@@ -3,17 +3,19 @@ from sso.services.jabber.ejabberdctl import eJabberdCtl
|
||||
import settings
|
||||
|
||||
class JabberService(BaseService):
|
||||
|
||||
corp_only = True
|
||||
|
||||
def __init__(self):
|
||||
self.ejctl = eJabberdCtl(sudo=settings.JABBER_SUDO)
|
||||
|
||||
def add_user(username, password):
|
||||
def add_user(self, username, password):
|
||||
""" Add user to service """
|
||||
return self.ejctl.register(username, settings.JABBER_SERVER, password)
|
||||
|
||||
def set_corp(self, username):
|
||||
""" User is in corp, enable extra privs """
|
||||
return self.ejctl.srg_user_add(username, settings.JABBER_SERVER, settings.JABBER_GROUP)
|
||||
pass
|
||||
|
||||
def delete_user(self, username):
|
||||
""" Delete a user """
|
||||
@@ -25,7 +27,7 @@ class JabberService(BaseService):
|
||||
|
||||
def enable_user(self, username):
|
||||
""" Enable a user """
|
||||
|
||||
return self.ejctl.enable_user(settings.JABBER_SERVER, username, password)
|
||||
|
||||
def check_user(self, username):
|
||||
""" Check if the username exists """
|
||||
|
||||
@@ -23,9 +23,12 @@ class eJabberdCtl():
|
||||
|
||||
args = []
|
||||
args.extend(self.ejctl)
|
||||
args.extend(shlex.split(commandline))
|
||||
args.extend(shlex.split(commandline.encode('ascii')))
|
||||
|
||||
print args
|
||||
# Convert all arguments to ascii first
|
||||
#args = map(lambda x: x.encode('ascii'), args)
|
||||
|
||||
print 'Executing: %s' % " ".join(args)
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
@@ -61,7 +64,7 @@ class eJabberdCtl():
|
||||
def register(self, user, server, password):
|
||||
""" Adds a user to a vhost """
|
||||
|
||||
cmd = "register %s %s %s" % (user, server, password)
|
||||
cmd = 'register %s %s %s' % (user, server, password)
|
||||
|
||||
try:
|
||||
self._execute(cmd)
|
||||
|
||||
Reference in New Issue
Block a user