mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-15 15:30:16 +02:00
Manual conflict resoltuion for pull request #98
This commit is contained in:
parent
fbabc97e74
commit
35277b7f33
@ -118,7 +118,9 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'util.context_processors.alliance_id',
|
||||
'util.context_processors.alliance_name',
|
||||
'util.context_processors.jabber_url',
|
||||
'util.context_processors.domain_url'
|
||||
'util.context_processors.domain_url',
|
||||
'util.context_processors.member_api_mask',
|
||||
'util.context_processors.blue_api_mask',
|
||||
)
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
@ -153,7 +155,7 @@ STATIC_ROOT = '/home/allianceserver/allianceauth/static/'
|
||||
|
||||
#####################################################
|
||||
##
|
||||
## Alliance configuration starts here
|
||||
## Auth configuration starts here
|
||||
##
|
||||
#####################################################
|
||||
|
||||
@ -247,6 +249,18 @@ CORP_API_VCODE = os.environ.get('AA_CORP_API_VCODE', '')
|
||||
ALLIANCE_ID = os.environ.get('AA_ALLIANCE_ID', '')
|
||||
ALLIANCE_NAME = os.environ.get('AA_ALLIANCE_NAME', '')
|
||||
|
||||
########################
|
||||
# API Configuration
|
||||
########################
|
||||
# MEMBER_API_MASK - Numeric value of minimum API mask required for members
|
||||
# MEMBER_API_ACCOUNT - Require API to be for Account and not character restricted
|
||||
# BLUE_API_MASK - Numeric value of minimum API mask required for blues
|
||||
# BLUE_API_ACCOUNT - Require API to be for Account and not character restricted
|
||||
#######################
|
||||
MEMBER_API_MASK = os.environ.get('AA_MEMBER_API_MASK', 268435455)
|
||||
MEMBER_API_ACCOUNT = 'True' == os.environ.get('AA_MEMBER_API_ACCOUNT', 'True')
|
||||
BLUE_API_MASK = os.environ.get('AA_BLUE_API_MASK', 8388608)
|
||||
BLUE_API_ACCOUNT = 'True' == os.environ.get('AA_BLUE_API_ACCOUNT', 'False')
|
||||
|
||||
#####################
|
||||
# HR Configuration
|
||||
|
@ -217,14 +217,32 @@ def run_api_refresh():
|
||||
for api_key_pair in api_key_pairs:
|
||||
print 'Running on ' + api_key_pair.api_id + ':' + api_key_pair.api_key
|
||||
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
|
||||
# Update characters
|
||||
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id,
|
||||
api_key_pair.api_key)
|
||||
EveManager.update_characters_from_list(characters)
|
||||
valid_key = True
|
||||
#check to ensure API key meets min spec
|
||||
still_valid = True
|
||||
if authserviceinfo.is_blue:
|
||||
if settings.BLUE_API_ACCOUNT:
|
||||
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
|
||||
still_valid = False
|
||||
if not EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
|
||||
still_valid = False
|
||||
else:
|
||||
if settings.MEMBER_API_ACCOUNT:
|
||||
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
|
||||
still_valid = False
|
||||
if not EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
|
||||
still_valid = False
|
||||
if still_valid is not True:
|
||||
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
|
||||
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
|
||||
else:
|
||||
# Update characters
|
||||
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id,
|
||||
api_key_pair.api_key)
|
||||
EveManager.update_characters_from_list(characters)
|
||||
valid_key = True
|
||||
else:
|
||||
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user)
|
||||
EveManager.delete_api_key_pair(api_key_pair.api_id, api_key_pair.api_key)
|
||||
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
|
||||
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
|
||||
|
||||
if valid_key:
|
||||
# Check our main character
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from services.managers.eve_api_manager import EveApiManager
|
||||
from eveonline.managers import EveManager
|
||||
@ -19,13 +20,24 @@ class UpdateKeyForm(forms.Form):
|
||||
except:
|
||||
pass
|
||||
|
||||
if not check_blue:
|
||||
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
|
||||
if check_blue:
|
||||
if settings.BLUE_API_ACCOUNT:
|
||||
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
|
||||
self.cleaned_data['api_key']):
|
||||
raise forms.ValidationError(u'API not of type account')
|
||||
|
||||
if not EveApiManager.check_blue_api_is_full(self.cleaned_data['api_id'],
|
||||
self.cleaned_data['api_key']):
|
||||
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.BLUE_API_MASK))
|
||||
|
||||
else:
|
||||
if settings.MEMBER_API_ACCOUNT:
|
||||
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
|
||||
self.cleaned_data['api_key']):
|
||||
raise forms.ValidationError(u'API not of type account')
|
||||
raise forms.ValidationError(u'API not of type account')
|
||||
|
||||
if not EveApiManager.check_api_is_full(self.cleaned_data['api_id'],
|
||||
self.cleaned_data['api_key']):
|
||||
raise forms.ValidationError(u'API supplied is not a full api key')
|
||||
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.MEMBER_API_MASK))
|
||||
|
||||
return self.cleaned_data
|
||||
|
@ -81,13 +81,24 @@ class EveApiManager():
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
account = evelink.account.Account(api=api)
|
||||
info = account.key_info()
|
||||
return info[0]['access_mask'] == 268435455
|
||||
return info[0]['access_mask'] >= int(settings.MEMBER_API_MASK)
|
||||
|
||||
except evelink.api.APIError as error:
|
||||
print error
|
||||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def check_blue_api_is_full(api_id, api_key):
|
||||
try:
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
account = evelink.account.Account(api=api)
|
||||
info = account.key_info()
|
||||
return info[0]['access_mask'] >= int(settings.BLUE_API_MASK)
|
||||
|
||||
except evelink.api.APIError as error:
|
||||
print error
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_api_info(api_id, api_key):
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<p class="text-center">
|
||||
<a target="_blank"
|
||||
href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=268435455">Create
|
||||
href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask={{MEMBER_API_MASK}}">Create
|
||||
a full API key</a>
|
||||
</p>
|
||||
{% if IS_CORP %}
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
<p class="text-center">
|
||||
<a target="_blank"
|
||||
href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=8388608">Create
|
||||
href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask={{BLUE_API_MASK}}">Create
|
||||
a blue key</a>
|
||||
</p>
|
||||
|
||||
|
@ -20,6 +20,11 @@ def alliance_name(request):
|
||||
def jabber_url(request):
|
||||
return {'JABBER_URL': settings.JABBER_URL}
|
||||
|
||||
def member_api_mask(request):
|
||||
return {'MEMBER_API_MASK': settings.MEMBER_API_MASK}
|
||||
|
||||
def blue_api_mask(request):
|
||||
return {'BLUE_API_MASK': settings.BLUE_API_MASK}
|
||||
|
||||
def domain_url(request):
|
||||
return {'DOMAIN': settings.DOMAIN, 'MUMBLE_URL': settings.MUMBLE_URL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user