mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Added basic mumble support
This commit is contained in:
parent
bf5a5b4bef
commit
89aa4fdcd3
@ -3,14 +3,14 @@ allianceauth
|
|||||||
|
|
||||||
Note: THIS WAS RUSHED! IT DOES NOT FOLLOW GOOD CODING STANDARDS
|
Note: THIS WAS RUSHED! IT DOES NOT FOLLOW GOOD CODING STANDARDS
|
||||||
Note2: Most importantly though it works....
|
Note2: Most importantly though it works....
|
||||||
Note3: Jabber uses inband registration. In prosody whitelist the auth server
|
|
||||||
|
|
||||||
Requirments:
|
Requirments:
|
||||||
django 1.7
|
django 1.6.1
|
||||||
python-mysql-connector
|
python-mysql-connector
|
||||||
python-mysqld
|
python-mysqld
|
||||||
django-evolution
|
django-evolution
|
||||||
python-passlib
|
python-passlib
|
||||||
|
python-evelink
|
||||||
python-openfire
|
python-openfire
|
||||||
bcrypt
|
bcrypt
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ WSGI_APPLICATION = 'allianceauth.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'allianceauth',
|
'NAME': 'alliance_auth',
|
||||||
'USER': 'allianceauth',
|
'USER': 'allianceauth',
|
||||||
'PASSWORD': 'allianceauth',
|
'PASSWORD': 'allianceauth',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
@ -92,6 +92,15 @@ DATABASES = {
|
|||||||
'PASSWORD': 'allianceauth',
|
'PASSWORD': 'allianceauth',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '3306',
|
'PORT': '3306',
|
||||||
|
},
|
||||||
|
|
||||||
|
'mumble': {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': 'alliance_mumble',
|
||||||
|
'USER': 'allianceauth',
|
||||||
|
'PASSWORD': 'allianceauth',
|
||||||
|
'HOST': '127.0.0.1',
|
||||||
|
'PORT': '3306',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +151,11 @@ STATIC_URL = '/static/'
|
|||||||
|
|
||||||
# ALLIANCE INFO
|
# ALLIANCE INFO
|
||||||
ALLIANCE_ID = 0
|
ALLIANCE_ID = 0
|
||||||
ALLIANCE_NAME = 'Some alliance here'
|
ALLIANCE_NAME = 'somealliance'
|
||||||
|
|
||||||
# Jabber Prosody Info
|
# Jabber Prosody Info
|
||||||
OPENFIRE_ADDRESS = "http://domain.com:9090/"
|
OPENFIRE_ADDRESS = "http://domain.com:9090/"
|
||||||
OPENFIRE_SECRET_KEY = "somekey"
|
OPENFIRE_SECRET_KEY = "secretkey"
|
||||||
|
|
||||||
|
# Mumble settings
|
||||||
|
MUMBLE_SERVER_ID = 1
|
@ -11,9 +11,10 @@ urlpatterns = patterns('',
|
|||||||
url(r'^characters/', 'portal.views.characters_view', name='characters'),
|
url(r'^characters/', 'portal.views.characters_view', name='characters'),
|
||||||
url(r'^apikeymanagment/', 'portal.views.apikeymanagment_view', name='apimanagment'),
|
url(r'^apikeymanagment/', 'portal.views.apikeymanagment_view', name='apimanagment'),
|
||||||
url(r'^maincharacterchange/(\d+)/$', 'portal.views.main_character_change', name='main_character_change'),
|
url(r'^maincharacterchange/(\d+)/$', 'portal.views.main_character_change', name='main_character_change'),
|
||||||
url(r'^applications/', 'portal.views.applications_view', name = 'applications'),
|
url(r'^applications/', 'portal.views.applications_view', name='applications'),
|
||||||
url(r'^activateforum/$', 'portal.views.activate_forum', name = 'activateforum'),
|
url(r'^activateforum/$', 'portal.views.activate_forum', name='activateforum'),
|
||||||
url(r'^activatejabber/$', 'portal.views.activate_jabber', name = 'activatejabber'),
|
url(r'^activatejabber/$', 'portal.views.activate_jabber', name='activatejabber'),
|
||||||
|
url(r'^activatemumble/$', 'portal.views.activate_mumble', name='activatemumble'),
|
||||||
url(r'^loginuser/','authentication.views.login_user', name='loginuser'),
|
url(r'^loginuser/','authentication.views.login_user', name='loginuser'),
|
||||||
url(r'^logoutuser/','authentication.views.logout_user', name='logoutuser'),
|
url(r'^logoutuser/','authentication.views.logout_user', name='logoutuser'),
|
||||||
url(r'^register/', 'registration.views.register', name='register'),
|
url(r'^register/', 'registration.views.register', name='register'),
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
from django.shortcuts import render_to_response, HttpResponseRedirect
|
from django.shortcuts import render_to_response, HttpResponseRedirect
|
||||||
|
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
from forms import UpdateKeyForm
|
from forms import UpdateKeyForm
|
||||||
|
|
||||||
from evespecific.managers import EveCharacterManager
|
from evespecific.managers import EveCharacterManager
|
||||||
from authentication.models import AllianceUserManager
|
from authentication.models import AllianceUserManager
|
||||||
from util.phpbb3_manager import Phpbb3Manager
|
from services.phpbb3_manager import Phpbb3Manager
|
||||||
from util.jabber_manager import JabberManager
|
from services.jabber_manager import JabberManager
|
||||||
|
from services.mumble_manager import MumbleManager
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@login_required
|
@login_required
|
||||||
@ -77,3 +79,18 @@ def activate_jabber(request):
|
|||||||
|
|
||||||
return HttpResponseRedirect("/")
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def activate_mumble(request):
|
||||||
|
userManager = AllianceUserManager()
|
||||||
|
characterManager = EveCharacterManager()
|
||||||
|
mumbleManager = MumbleManager()
|
||||||
|
|
||||||
|
if userManager.check_if_user_exist(request.user.id):
|
||||||
|
characterManager = EveCharacterManager()
|
||||||
|
character = characterManager.get_character_by_id(request.user.main_char_id)
|
||||||
|
|
||||||
|
mumbleManager.create_user(character.character_name, "test")
|
||||||
|
|
||||||
|
return HttpResponseRedirect("/applications/")
|
||||||
|
|
||||||
|
return HttpResponseRedirect("/")
|
@ -28,4 +28,4 @@ def register(request):
|
|||||||
else:
|
else:
|
||||||
form = RegistrationForm()
|
form = RegistrationForm()
|
||||||
|
|
||||||
return render_to_response('public/register.html',{'form':form}, context_instance=RequestContext(request))
|
return render_to_response('public/register.html', {'form': form}, context_instance=RequestContext(request))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connections, transaction
|
|
||||||
from openfire import UserService
|
from openfire import UserService
|
||||||
|
|
||||||
|
|
||||||
class JabberManager():
|
class JabberManager():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -15,15 +15,15 @@ class JabberManager():
|
|||||||
|
|
||||||
def delete_user(self, username):
|
def delete_user(self, username):
|
||||||
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
||||||
api.delete_user(username, password)
|
api.delete_user(username)
|
||||||
|
|
||||||
def lock_user(self, username):
|
def lock_user(self, username):
|
||||||
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
||||||
api.lock_user(username, password)
|
api.lock_user(username)
|
||||||
|
|
||||||
def unlock_user(self, username):
|
def unlock_user(self, username):
|
||||||
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
||||||
api.unlock_user(username, password)
|
api.unlock_user(username)
|
||||||
|
|
||||||
def update_user_pass(self, username, password):
|
def update_user_pass(self, username, password):
|
||||||
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
|
52
services/mumble_manager.py
Normal file
52
services/mumble_manager.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import uuid
|
||||||
|
import hashlib
|
||||||
|
import random
|
||||||
|
from django.db import connections
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
class MumbleManager:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.dbcursor = connections['mumble'].cursor()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _gen_pwhash(password):
|
||||||
|
return hashlib.sha1(password).hexdigest()
|
||||||
|
|
||||||
|
def get_user_id_by_name(self, name):
|
||||||
|
self.dbcursor.execute(r"SELECT user_id from murmur_users WHERE name = %s AND server_id = %s",
|
||||||
|
[name, settings.MUMBLE_SERVER_ID])
|
||||||
|
row = self.dbcursor.fetchone()
|
||||||
|
if row:
|
||||||
|
return row[0]
|
||||||
|
|
||||||
|
def create_user(self, username, password):
|
||||||
|
""" Add a user """
|
||||||
|
self.dbcursor.execute(r"SELECT max(user_id)+1 as next_id from murmur_users")
|
||||||
|
user_id = self.dbcursor.fetchone()[0]
|
||||||
|
|
||||||
|
self.dbcursor.execute(r"INSERT INTO murmur_users (server_id, user_id, name, pw) VALUES (%s, %s, %s, %s)",
|
||||||
|
[settings.MUMBLE_SERVER_ID, user_id, self.__santatize_username(username), self._gen_pwhash(password)])
|
||||||
|
|
||||||
|
return {'username': username, 'password': password }
|
||||||
|
|
||||||
|
def check_user_exist(self, username):
|
||||||
|
""" Check if the username exists """
|
||||||
|
self.dbcursor.execute(r"SELECT name from murmur_users WHERE name = %s AND server_id = %s",
|
||||||
|
[username, settings.MUMBLE_SERVER_ID])
|
||||||
|
|
||||||
|
row = self.dbcursor.fetchone()
|
||||||
|
if row and row[0].lower() == username.lower():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def delete_user(self, uid):
|
||||||
|
""" Delete a user """
|
||||||
|
id = self.get_user_id_by_name(uid)
|
||||||
|
self.dbcursor.execute(r"DELETE FROM murmur_users WHERE user_id = %s AND server_id = %s",
|
||||||
|
[id, settings.MUMBLE_SERVER_ID])
|
||||||
|
return True
|
||||||
|
|
||||||
|
def __santatize_username(self, username):
|
||||||
|
sanatized = username.replace(" ","_")
|
||||||
|
return sanatized.lower()
|
@ -1,17 +1,23 @@
|
|||||||
import hashlib
|
|
||||||
import random
|
import random
|
||||||
from passlib.apps import phpbb3_context
|
from passlib.apps import phpbb3_context
|
||||||
from django.conf import settings
|
from django.db import connections
|
||||||
from django.db import connections, transaction
|
|
||||||
|
|
||||||
class Phpbb3Manager():
|
class Phpbb3Manager():
|
||||||
|
|
||||||
SQL_ADD_USER = r"INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id , user_permissions, user_sig, user_occ, user_interests) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
SQL_ADD_USER = r"INSERT INTO phpbb_users (username, username_clean, " \
|
||||||
SQL_DIS_USER = r"DELETE FROM phpbb_user_groups where user_id = (SELECT user_id FROM phpbb_users WHERE username = %s)"
|
r"user_password, user_email, group_id , user_permissions, " \
|
||||||
|
r"user_sig, user_occ, user_interests) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
|
|
||||||
|
SQL_DIS_USER = r"DELETE FROM phpbb_user_groups where user_id = " \
|
||||||
|
r"(SELECT user_id FROM phpbb_users WHERE username = %s)"
|
||||||
|
|
||||||
SQL_CHECK_USER = r"SELECT user_id from phpbb_users WHERE username = %s"
|
SQL_CHECK_USER = r"SELECT user_id from phpbb_users WHERE username = %s"
|
||||||
|
|
||||||
SQL_ADD_USER_GROUP = r"INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (%s, %s, %s)"
|
SQL_ADD_USER_GROUP = r"INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (%s, %s, %s)"
|
||||||
|
|
||||||
SQL_GET_GROUP = r"SELECT group_id from phpbb_groups WHERE group_name = %s"
|
SQL_GET_GROUP = r"SELECT group_id from phpbb_groups WHERE group_name = %s"
|
||||||
|
|
||||||
SQL_ADD_GROUP = r"INSERT INTO phpbb_groups (group_name) VALUES (%s)"
|
SQL_ADD_GROUP = r"INSERT INTO phpbb_groups (group_name) VALUES (%s)"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
@ -12,6 +12,8 @@
|
|||||||
<p> Click button to add user to services</p>
|
<p> Click button to add user to services</p>
|
||||||
<a href="/activateforum/"><button type="button" class="btn btn-default">Activate Forum</button></a>
|
<a href="/activateforum/"><button type="button" class="btn btn-default">Activate Forum</button></a>
|
||||||
<a href="/activatejabber/"><button type="button" class="btn btn-default">Activate Jabber</button></a>
|
<a href="/activatejabber/"><button type="button" class="btn btn-default">Activate Jabber</button></a>
|
||||||
|
<a href="/activatemumble/"><button type="button" class="btn btn-default">Activate Jabber</button></a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user