diff --git a/alliance_auth/settings.py.example b/alliance_auth/settings.py.example index 271eace0..ce81d9f7 100644 --- a/alliance_auth/settings.py.example +++ b/alliance_auth/settings.py.example @@ -61,7 +61,7 @@ INSTALLED_APPS = [ 'corputils', 'fleetactivitytracking', 'notifications', - 'eve_sso', + 'esi', 'geelweb.django.navhelper', ] @@ -237,9 +237,9 @@ FORUM_URL = os.environ.get('AA_FORUM_URL', '') # Callback URL should be http://mydomain.com/sso/callback # Leave callback blank to hide SSO button on login page ################### -EVE_SSO_CLIENT_ID = os.environ.get('AA_EVE_SSO_CLIENT_ID', '') -EVE_SSO_CLIENT_SECRET = os.environ.get('AA_EVE_SSO_CLIENT_SECRET', '') -EVE_SSO_CALLBACK_URL = os.environ.get('AA_EVE_SSO_CALLBACK_URL', '') +ESI_SSO_CLIENT_ID = os.environ.get('AA_EVE_SSO_CLIENT_ID', '') +ESI_SSO_CLIENT_SECRET = os.environ.get('AA_EVE_SSO_CLIENT_SECRET', '') +ESI_SSO_CALLBACK_URL = os.environ.get('AA_EVE_SSO_CALLBACK_URL', '') ######################### # Default Group Settings diff --git a/alliance_auth/urls.py b/alliance_auth/urls.py index 29613fc5..1a1e770c 100755 --- a/alliance_auth/urls.py +++ b/alliance_auth/urls.py @@ -16,7 +16,7 @@ import fleetup.views import srp.views import notifications.views import hrapplications.views -import eve_sso.urls +import esi.urls # Functional/Untranslated URL's urlpatterns = [ @@ -27,7 +27,7 @@ urlpatterns = [ url(r'^admin/', include(admin.site.urls)), # SSO - url (r'^sso/', include(eve_sso.urls, namespace='eve_sso')), + url (r'^sso/', include(esi.urls, namespace='esi')), url (r'^sso/login$', authentication.views.sso_login, name='auth_sso_login'), # Index diff --git a/authentication/views.py b/authentication/views.py index 745a74bd..9124cfd2 100644 --- a/authentication/views.py +++ b/authentication/views.py @@ -10,7 +10,7 @@ from authentication.models import AuthServicesInfo from authentication.forms import LoginForm, RegistrationForm from django.contrib.auth.models import User from django.contrib import messages -from eve_sso.decorators import token_required +from esi.decorators import token_required import logging logger = logging.getLogger(__name__) @@ -102,13 +102,14 @@ def help_view(request): return render(request, 'registered/help.html') @token_required(new=True) -def sso_login(request, tokens=[]): - token = tokens[0] +def sso_login(request, token): try: char = EveCharacter.objects.get(character_id=token.character_id) if char.user: if char.user.is_active: login(request, char.user) + token.user = char.user + token.save() return redirect(dashboard_view) else: messages.error(request, 'Your account has been disabled.') diff --git a/eveonline/views.py b/eveonline/views.py index 51727f3b..27a958fe 100755 --- a/eveonline/views.py +++ b/eveonline/views.py @@ -12,7 +12,7 @@ from authentication.models import AuthServicesInfo from authentication.tasks import set_state from eveonline.tasks import refresh_api -from eve_sso.decorators import token_required +from esi.decorators import token_required from django.conf import settings import logging @@ -70,7 +70,7 @@ def add_api_key(request): @login_required @token_required(new=True) -def api_sso_validate(request, tokens, api_id): +def api_sso_validate(request, token, api_id): logger.debug('api_sso_validate called by user %s for api %s' % (request.user, api_id)) api = get_object_or_404(EveApiKeyPair, api_id=api_id) if api.user and api.user != request.user: @@ -81,7 +81,6 @@ def api_sso_validate(request, tokens, api_id): logger.debug('API %s has already been verified.' % api_id) messages.info(request, 'API %s has already been verified' % api_id) return redirect('auth_api_key_management') - token = tokens[0] logger.debug('API %s has not been verified. Checking if token for %s matches.' % (api_id, token.character_name)) characters = EveApiManager.get_characters_from_api(api.api_id, api.api_key).result if token.character_id in characters: diff --git a/requirements.txt b/requirements.txt index aa50fe15..a1d00830 100755 --- a/requirements.txt +++ b/requirements.txt @@ -22,4 +22,4 @@ git+https://github.com/celery/django-celery git+git://github.com/nikdoof/python-ts3.git git+https://github.com/pyghassen/openfire-restapi -git+https://github.com/adarnof/adarnauth-eve-sso +git+https://github.com/adarnof/adarnauth-esi