Merge pull request #1 from Adarnof/temp

Merge changes in temp branch to orgin toggle branch
This commit is contained in:
Adarnof 2015-10-31 18:32:10 -04:00
commit 8945cf3a2a
16 changed files with 147 additions and 63 deletions

View File

@ -20,6 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# Generate a new key here: http://www.miniwebtool.com/django-secret-key-generator/
SECRET_KEY = os.environ.get('AA_SECRET_KEY', '5xvh4e0x&@-$6(kj%4^80pdo1n5v-!mtx(e(1tw@kn-1le*ts@')
# SECURITY WARNING: don't run with debug turned on in production!
@ -111,8 +112,11 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'util.context_processors.is_corp',
'util.context_processors.corp_id',
'util.context_processors.corp_name',
'util.context_processors.alliance_id',
'util.context_processors.alliance_name',
'util.context_processors.jabber_url',
'util.context_processors.domain_url'
)
@ -166,7 +170,7 @@ IS_CORP = 'False' == os.environ.get('AA_IS_CORP', 'True')
# DOMAIN - The alliance auth domain_url
# EMAIL_HOST - SMTP Server URL
# EMAIL_PORT - SMTP Server PORT
# EMAIL_HOST_USER - Email Username
# EMAIL_HOST_USER - Email Username (for gmail, the part before @gmail.com)
# EMAIL_HOST_PASSWORD - Email Password
# EMAIL_USE_TLS - Set to use TLS encryption
#################
@ -203,11 +207,13 @@ ENABLE_AUTH_TEAMSPEAK3 = 'True' == os.environ.get('AA_ENABLE_AUTH_TEAMSPEAK3', '
#####################
# Blue service Setup
#####################
# BLUE_STANDING - The default lowest standings setting to consider blue
# ENABLE_BLUE_FORUM - Enable forum support in the auth for blues
# ENABLE_BLUE_JABBER - Enable jabber support in the auth for blues
# ENABLE_BLUE_MUMBLE - Enable mumble support in the auth for blues
# ENABLE_BLUE_IPBOARD - Enable IPBoard forum support in the auth for blues
#####################
BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0'))
ENABLE_BLUE_FORUM = 'True' == os.environ.get('AA_ENABLE_BLUE_FORUM', 'False')
ENABLE_BLUE_JABBER = 'True' == os.environ.get('AA_ENABLE_BLUE_JABBER', 'False')
ENABLE_BLUE_MUMBLE = 'True' == os.environ.get('AA_ENABLE_BLUE_MUMBLE', 'True')
@ -217,26 +223,23 @@ ENABLE_BLUE_TEAMSPEAK3 = 'True' == os.environ.get('AA_ENABLE_BLUE_TEAMSPEAK3', '
#########################
# Corp Configuration
#########################
# If running in alliance mode, the following should be for the executor corp#
# CORP_ID - Set this to your corp ID (get this from https://zkillboard.com/corporation/#######)
# CORP_NAME - Set this to your Corporation Name
# CORP_API_ID - Set this to the api id for the corp API key
# CORP_API_VCODE - Set this to the api vcode for the corp API key
# BLUE_STANDING - The default lowest standings setting to consider blue
########################
CORP_ID = os.environ.get('AA_CORP_ID', '')
CORP_NAME = os.environ.get('AA_CORP_NAME', '')
CORP_API_ID = os.environ.get('AA_CORP_API_ID', '')
CORP_API_VCODE = os.environ.get('AA_CORP_API_VCODE', '')
BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0'))
#########################
# Alliance Configuration
#########################
# ALLIANCE_ID - Set this to your corp ID (get this from https://zkillboard.com/corporation/#######)
# ALLIANCE_NAME - Set this to your Corporation Name
# ALLIANCE_API_ID - Set this to the api id for the corp API key
# ALLIANCE_API_VCODE - Set this to the api vcode for the corp API key
# BLUE_STANDING - The default lowest standings setting to consider blue
# ALLIANCE_ID - Set this to your Alliance ID (get this from https://zkillboard.com/alliance/#######)
# ALLIANCE_NAME - Set this to your Alliance Name
########################
ALLIANCE_ID = os.environ.get('AA_ALLIANCE_ID', '')
ALLIANCE_NAME = os.environ.get('AA_ALLIANCE_NAME', '')
@ -258,7 +261,7 @@ JACK_KNIFE_URL = os.environ.get('AA_JACK_KNIFE_URL', 'http://ridetheclown.com/ev
# IPBOARD_APIKEY - Api key to interact with ipboard
# IPBOARD_APIMODULE - Module for alliance auth *leave alone*
#####################
FORUM_URL = os.environ.get('AA_FORUM_URL', "")
FORUM_URL = os.environ.get('AA_FORUM_URL', "http://someurl.com")
IPBOARD_ENDPOINT = os.environ.get('AA_IPBOARD_ENDPOINT', 'someaddress.com/interface/board/index.php')
IPBOARD_APIKEY = os.environ.get('AA_IPBOARD_APIKEY', 'somekeyhere')
IPBOARD_APIMODULE = 'aa'
@ -269,15 +272,16 @@ IPBOARD_APIMODULE = 'aa'
# JABBER_URL - Jabber address url
# JABBER_PORT - Jabber service portal
# JABBER_SERVER - Jabber server url
# OPENFIRE_ADDRESS - Address of the openfire admin console
# OPENFIRE_SECRET_KEY - Openfire userservice secret key
# OPENFIRE_ADDRESS - Address of the openfire admin console including port
# Please use http with 9090 or https with 9091
# OPENFIRE_SECRET_KEY - Openfire REST API secret key
# BROADCAST_USER - Broadcast user JID
# BROADCAST_USER_PASSWORD - Broadcast user password
######################
JABBER_URL = os.environ.get('AA_JABBER_URL', "")
JABBER_URL = os.environ.get('AA_JABBER_URL', "someurl.com")
JABBER_PORT = int(os.environ.get('AA_JABBER_PORT', '5223'))
JABBER_SERVER = os.environ.get('AA_JABBER_SERVER', "")
OPENFIRE_ADDRESS = os.environ.get('AA_OPENFIRE_ADDRESS', "")
JABBER_SERVER = os.environ.get('AA_JABBER_SERVER', "someurl.com")
OPENFIRE_ADDRESS = os.environ.get('AA_OPENFIRE_ADDRESS', "http://someurl.com:9090")
OPENFIRE_SECRET_KEY = os.environ.get('AA_OPENFIRE_SECRET_KEY', "somekey")
BROADCAST_USER = os.environ.get('AA_BROADCAST_USER', "broadcast@") + JABBER_URL
BROADCAST_USER_PASSWORD = os.environ.get('AA_BROADCAST_USER_PASSWORD', "somepassword")
@ -288,7 +292,7 @@ BROADCAST_USER_PASSWORD = os.environ.get('AA_BROADCAST_USER_PASSWORD', "somepass
# MUMBLE_URL - Mumble server url
# MUMBLE_SERVER_ID - Mumble server id
######################################
MUMBLE_URL = os.environ.get('AA_MUMBLE_URL', "")
MUMBLE_URL = os.environ.get('AA_MUMBLE_URL', "someurl.com")
MUMBLE_SERVER_ID = int(os.environ.get('AA_MUMBLE_SERVER_ID', '1'))
######################################
@ -302,7 +306,7 @@ MUMBLE_SERVER_ID = int(os.environ.get('AA_MUMBLE_SERVER_ID', '1'))
# TEAMSPEAK3_AUTHED_GROUP_ID - Default authed group id
# TEAMSPEAK3_PUBLIC_URL - teamspeak3 public url used for link creation
######################################
TEAMSPEAK3_SERVER_IP = os.environ.get('AA_TEAMSPEAK3_SERVER_IP', '')
TEAMSPEAK3_SERVER_IP = os.environ.get('AA_TEAMSPEAK3_SERVER_IP', '127.0.0.1')
TEAMSPEAK3_SERVER_PORT = int(os.environ.get('AA_TEAMSPEAK3_SERVER_PORT', '10011'))
TEAMSPEAK3_SERVERQUERY_USER = os.environ.get('AA_TEAMSPEAK3_SERVERQUERY_USER', 'serveradmin')
TEAMSPEAK3_SERVERQUERY_PASSWORD = os.environ.get('AA_TEAMSPEAK3_SERVERQUERY_PASSWORD', 'passwordhere')

View File

@ -1 +0,0 @@
28392

View File

@ -225,7 +225,8 @@ def run_api_refresh():
character = EveManager.get_character_by_id(authserviceinfo.main_char_id)
corp = EveManager.get_corporation_info_by_id(character.corporation_id)
main_corp_id = EveManager.get_charater_corporation_id_by_id(authserviceinfo.main_char_id)
if main_corp_id == settings.CORP_ID:
main_alliance_id = EveManager.get_charater_alliance_id_by_id(authserviceinfo.main_char_id)
if (settings.IS_CORP and main_corp_id == settings.CORP_ID) or (not settings.IS_CORP and main_alliance_id == settings.ALLIANCE_ID):
if not check_if_user_has_permission(user, "member"):
#transition from blue to member
if check_if_user_has_permission(user, "blue_member"):
@ -237,29 +238,38 @@ def run_api_refresh():
elif corp is not None:
if corp.is_blue is not True:
if check_if_user_has_permission(user, "member"):
#transition from member to nobody
disable_alliance_member(user, authserviceinfo.main_char_id)
elif check_if_user_has_permission(user, "blue_member"):
#transition from blue to nobody
disable_blue_member(user)
else:
#stay nobody, make sure no services
deactivate_services(user)
else:
change_status = False
if check_if_user_has_permission(user, "member"):
remove_member_permission(user, "member")
remove_user_from_group(user, settings.DEFAULT_AUTH_GROUP)
#remove auth member to prepare for member to blue transition
disable_alliance_member(user, authserviceinfo.main_char_id)
change_status = True
if not check_if_user_has_permission(user, "blue_member"):
#perform member to blue transition
add_member_permission(user, "blue_member")
add_user_to_group(user, settings.DEFAULT_BLUE_GROUP)
#Fix mumble username ticker
MumbleManager.delete_user(authserviceinfo.mumble_username)
remove_all_syncgroups_for_service(user, "mumble")
AuthServicesInfoManager.update_user_mumble_info("", "", request.user)
#make new user (how generous)
result = MumbleManager.create_blue_user(character.corporation_ticker, character.character_name)
AuthServicesInfoManager.update_user_mumble_info(result[0], result[1], user)
update_mumble_groups(request.user)
change_status = True
#if user has mumble account, rename it with proper ticker
if (not authserviceinfo.mumble_username == "") and change_status:
#Fix mumble username ticker
MumbleManager.delete_user(authserviceinfo.mumble_username)
remove_all_syncgroups_for_service(user, "mumble")
AuthServicesInfoManager.update_user_mumble_info("", "", request.user)
#make new user (how generous)
result = MumbleManager.create_blue_user(character.corporation_ticker, character.character_name)
AuthServicesInfoManager.update_user_mumble_info(result[0], result[1], user)
update_mumble_groups(request.user)
else:
# disable accounts with missing corp data
if check_if_user_has_permission(user, "member"):
disable_alliance_member(user, authserviceinfo.main_char_id)
elif check_if_user_has_permission(user, "blue_member"):
@ -268,7 +278,7 @@ def run_api_refresh():
deactivate_services(user)
else:
# nuke it
# disable accounts with invalid keys
if check_if_user_has_permission(user, "member"):
disable_alliance_member(user, authserviceinfo.main_char_id)
elif check_if_user_has_permission(user, "blue_member"):
@ -286,12 +296,27 @@ def run_corp_update():
# I am not proud of this block of code
if EveApiManager.check_if_api_server_online():
# Create the corp
corpinfo = EveApiManager.get_corporation_information(settings.CORP_ID)
if not EveManager.check_if_corporation_exists_by_id(corpinfo['id']):
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], False, None)
if settings.IS_CORP:
# Create the corp
corpinfo = EveApiManager.get_corporation_information(settings.CORP_ID)
if not EveManager.check_if_corporation_exists_by_id(corpinfo['id']):
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], False, None)
else:
# Updated alliance info
alliance_info = EveApiManager.get_alliance_information(settings.ALLIANCE_ID)
# Populate alliance info
if not EveManager.check_if_alliance_exists_by_id(settings.ALLIANCE_ID):
EveManager.create_alliance_info(settings.ALLIANCE_ID, alliance_info['name'], alliance_info['ticker'],
alliance_info['executor_id'], alliance_info['member_count'], False)
alliance = EveManager.get_alliance_info_by_id(settings.ALLIANCE_ID)
# Create the corps in the alliance
for alliance_corp in alliance_info['member_corps']:
corpinfo = EveApiManager.get_corporation_information(alliance_corp)
if not EveManager.check_if_corporation_exists_by_id(corpinfo['id']):
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], False, alliance)
#determine what level of standings to check
#refer to https://github.com/eve-val/evelink/blob/master/evelink/parsing/contact_list.py#L43
@ -333,7 +358,10 @@ def run_corp_update():
# Update all allinace info's
for all_alliance_info in EveManager.get_all_alliance_info():
all_alliance_api_info = EveApiManager.get_alliance_information(all_alliance_info.alliance_id)
if standing_level in corp_standings:
if (not settings.IS_CORP and all_alliance_info.alliance_id == settings.ALLIANCE_ID):
EveManager.update_alliance_info(all_alliance_api_info['id'], all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], False)
elif standing_level in corp_standings:
if int(all_alliance_info.alliance_id) in corp_standings[standing_level]:
if int(corp_standings[standing_level][int(all_alliance_info.alliance_id)][
'standing']) >= settings.BLUE_STANDING:
@ -362,7 +390,9 @@ def run_corp_update():
if alliance is not None and all_corp_info.alliance is not None:
if int(alliance.alliance_id) in corp_standings[standing_level]:
if (not settings.IS_CORP) and (all_corp_info.alliance.alliance_id == settings.ALLIANCE_ID):
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance, False)
elif int(alliance.alliance_id) in corp_standings[standing_level]:
if int(corp_standings[standing_level][int(alliance.alliance_id)][
'standing']) >= settings.BLUE_STANDING:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance,
@ -383,15 +413,18 @@ def run_corp_update():
else:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], None, False)
# Nuke the none believers
# Remove irrelevent corp and alliance models
# Check the corps
for all_corp_info in EveManager.get_all_corporation_info():
if all_corp_info.corporation_id != settings.CORP_ID:
if (settings.IS_CORP and all_corp_info.corporation_id != settings.CORP_ID) or (not settings.IS_CORP and all_corp_info.alliance_id != settings.ALLIANCE_ID):
if not all_corp_info.is_blue:
all_corp_info.delete()
# Check the alliances
for all_alliance_info in EveManager.get_all_alliance_info():
if (not settings.IS_CORP and all_alliance_info.alliance_id != settings.ALLIANCE_ID):
if all_alliance_info.is_blue is not True:
all_alliance_info.delete()
if all_alliance_info.is_blue is not True:
all_alliance_info.delete()

View File

@ -7,7 +7,7 @@ from eveonline.managers import EveManager
class UpdateKeyForm(forms.Form):
api_id = forms.CharField(max_length=254, required=True, label="Key ID")
api_key = forms.CharField(max_length=254, required=True, label="Verification Code")
is_blue = forms.BooleanField(label="Blue to corp", required=False)
is_blue = forms.BooleanField(label="Blue to corp/alliance", required=False)
def clean(self):
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):

View File

@ -104,7 +104,7 @@ def main_character_change(request, char_id):
character_info = EveManager.get_character_by_id(char_id)
corporation_info = EveManager.get_corporation_info_by_id(character_info.corporation_id)
if EveManager.get_charater_corporation_id_by_id(char_id) == settings.CORP_ID:
if (settings.IS_CORP and EveManager.get_charater_corporation_id_by_id(char_id) == settings.CORP_ID) or (not settings.IS_CORP and EveManager.get_charater_alliance_id_by_id(char_id) == settings.ALLIANCE_ID):
add_member_permission(request.user, 'member')
add_user_to_group(request.user, settings.DEFAULT_AUTH_GROUP)
add_user_to_group(request.user,

View File

@ -10,9 +10,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>{{ CORP_NAME }} - Login</title>
{% if IS_CORP %}
<title>{{ CORP_NAME }} - Login</title>
{% else %}
<title>{{ ALLIANCE_NAME }} - Login</title>
{% endif %}
<!-- Bootstrap Core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<!-- Custom Fonts -->

View File

@ -10,7 +10,11 @@
<meta name="description" content="">
<meta name="author" content="">
<title>{{ CORP_NAME }} - Login</title>
{% if IS_CORP %}
<title>{{ CORP_NAME }} - Login</title>
{% else %}
<title>{{ ALLIANCE_NAME }} - Login</title>
{% endif %}
<!-- Bootstrap Core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

View File

@ -23,12 +23,19 @@
href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=268435455">Create
a full API key</a>
</p>
<p class="text-center">
NOTE: If you are part of the corp do not check "Blue" this is for people who are blue to the
corp
but are not in it. Blue access is limited.
</p>
{% if IS_CORP %}
<p class="text-center">
NOTE: If you are part of the corp do not check "Blue", this is for people who are blue to the
corp
but are not in it. Blue access is limited.
</p>
{% else %}
<p class="text-center">
NOTE: If you are part of the alliance do not check "Blue", this is for people who are blue to the
alliance
but are not in it. Blue access is limited.
</p>
{% endif %}
<p class="text-center"><b>Do not change the accessmask or deselect options or it will not work </b>
</p>

View File

@ -67,7 +67,11 @@
</div>
</div>
{% else %}
<p> Not part of the corporation</p>
{% if IS_CORP %}
<div class="alert alert-danger" role="alert">You are not in the corporation.</div>
{% else %}
<div class="alert alert-danger" role="alert">You are not in the alliance.</div>
{% endif %}
{% endif %}
</div>
{% endblock content %}

View File

@ -1,6 +1,6 @@
{% extends "public/base.html" %}
{% block title %}Alliance Auth{% endblock %}
{% block page_title %}Something something here{% endblock page_title %}
{% block page_title %}Dashboard{% endblock page_title %}
{% block content %}
@ -59,7 +59,11 @@
</div>
</div>
{% else %}
<p> Not part of the corporation</p>
{% if IS_CORP %}
<p> Not part of the corporation.</p>
{% else %}
<p> Not part of the alliance.</p>
{% endif %}
{% endif %}
</div>
{% endblock content %}

View File

@ -52,7 +52,11 @@
{% endfor %}
</table>
{% else %}
<div class="alert alert-danger" role="alert">You are not in the corporation</div>
{% if IS_CORP %}
<div class="alert alert-danger" role="alert">You are not in the corporation.</div>
{% else %}
<div class="alert alert-danger" role="alert">You are not in the alliance.</div>
{% endif %}
{% endif %}
</div>

View File

@ -300,7 +300,11 @@
{% endif %}
</table>
{% else %}
<div class="alert alert-danger" role="alert">You are not in the corporation</div>
{% if IS_CORP %}
<div class="alert alert-danger" role="alert">You are not in the corporation.</div>
{% else %}
<div class="alert alert-danger" role="alert">You are not in the alliance.</div>
{% endif %}
{% endif %}
</div>

View File

@ -12,7 +12,11 @@
<meta name="description" content="">
<meta name="author" content="">
<title>{{ CORP_NAME }} - Login</title>
{% if IS_CORP %}
<title>{{ CORP_NAME }} - Login</title>
{% else %}
<title>{{ ALLIANCE_NAME }} - Login</title>
{% endif %}
<!-- Bootstrap Core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

View File

@ -12,8 +12,11 @@
<meta name="description" content="">
<meta name="author" content="">
<title>{{ CORP_NAME }} - Login</title>
{% if IS_CORP %}
<title>{{ CORP_NAME }} - Login</title>
{% else %}
<title>{{ ALLIANCE_NAME }} - Login</title>
{% endif %}
<!-- Bootstrap Core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<!-- Custom Fonts -->

View File

@ -12,7 +12,11 @@
<meta name="description" content="">
<meta name="author" content="">
<title>{{ CORP_NAME }} - Login</title>
{% if IS_CORP %}
<title>{{ CORP_NAME }} - Login</title>
{% else %}
<title>{{ ALLIANCE_NAME }} - Login</title>
{% endif %}
<!-- Bootstrap Core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

View File

@ -2,13 +2,20 @@ from django.conf import settings
from django.utils import timezone
def is_corp(request):
return {'IS_CORP': settings.IS_CORP}
def corp_id(request):
return {'CORP_ID': settings.CORP_ID}
def corp_name(request):
return {'CORP_NAME': settings.CORP_NAME}
def alliance_id(request):
return {'ALLIANCE_ID': settings.ALLIANCE_ID}
def alliance_name(request):
return {'ALLIANCE_NAME': settings.CORP_NAME}
def jabber_url(request):
return {'JABBER_URL': settings.JABBER_URL}