Migrate to adarnauth-esi

This commit is contained in:
Adarnof 2016-12-11 20:11:05 -05:00
parent 961b26a3cb
commit a630b5b397
5 changed files with 13 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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.')

View File

@ -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:

View File

@ -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