mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 06:20:16 +02:00
Migrate to adarnauth-esi
This commit is contained in:
parent
961b26a3cb
commit
a630b5b397
@ -61,7 +61,7 @@ INSTALLED_APPS = [
|
|||||||
'corputils',
|
'corputils',
|
||||||
'fleetactivitytracking',
|
'fleetactivitytracking',
|
||||||
'notifications',
|
'notifications',
|
||||||
'eve_sso',
|
'esi',
|
||||||
'geelweb.django.navhelper',
|
'geelweb.django.navhelper',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -237,9 +237,9 @@ FORUM_URL = os.environ.get('AA_FORUM_URL', '')
|
|||||||
# Callback URL should be http://mydomain.com/sso/callback
|
# Callback URL should be http://mydomain.com/sso/callback
|
||||||
# Leave callback blank to hide SSO button on login page
|
# Leave callback blank to hide SSO button on login page
|
||||||
###################
|
###################
|
||||||
EVE_SSO_CLIENT_ID = os.environ.get('AA_EVE_SSO_CLIENT_ID', '')
|
ESI_SSO_CLIENT_ID = os.environ.get('AA_EVE_SSO_CLIENT_ID', '')
|
||||||
EVE_SSO_CLIENT_SECRET = os.environ.get('AA_EVE_SSO_CLIENT_SECRET', '')
|
ESI_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_CALLBACK_URL = os.environ.get('AA_EVE_SSO_CALLBACK_URL', '')
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Default Group Settings
|
# Default Group Settings
|
||||||
|
@ -16,7 +16,7 @@ import fleetup.views
|
|||||||
import srp.views
|
import srp.views
|
||||||
import notifications.views
|
import notifications.views
|
||||||
import hrapplications.views
|
import hrapplications.views
|
||||||
import eve_sso.urls
|
import esi.urls
|
||||||
|
|
||||||
# Functional/Untranslated URL's
|
# Functional/Untranslated URL's
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -27,7 +27,7 @@ urlpatterns = [
|
|||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
# SSO
|
# 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'),
|
url (r'^sso/login$', authentication.views.sso_login, name='auth_sso_login'),
|
||||||
|
|
||||||
# Index
|
# Index
|
||||||
|
@ -10,7 +10,7 @@ from authentication.models import AuthServicesInfo
|
|||||||
from authentication.forms import LoginForm, RegistrationForm
|
from authentication.forms import LoginForm, RegistrationForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from eve_sso.decorators import token_required
|
from esi.decorators import token_required
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -102,13 +102,14 @@ def help_view(request):
|
|||||||
return render(request, 'registered/help.html')
|
return render(request, 'registered/help.html')
|
||||||
|
|
||||||
@token_required(new=True)
|
@token_required(new=True)
|
||||||
def sso_login(request, tokens=[]):
|
def sso_login(request, token):
|
||||||
token = tokens[0]
|
|
||||||
try:
|
try:
|
||||||
char = EveCharacter.objects.get(character_id=token.character_id)
|
char = EveCharacter.objects.get(character_id=token.character_id)
|
||||||
if char.user:
|
if char.user:
|
||||||
if char.user.is_active:
|
if char.user.is_active:
|
||||||
login(request, char.user)
|
login(request, char.user)
|
||||||
|
token.user = char.user
|
||||||
|
token.save()
|
||||||
return redirect(dashboard_view)
|
return redirect(dashboard_view)
|
||||||
else:
|
else:
|
||||||
messages.error(request, 'Your account has been disabled.')
|
messages.error(request, 'Your account has been disabled.')
|
||||||
|
@ -12,7 +12,7 @@ from authentication.models import AuthServicesInfo
|
|||||||
from authentication.tasks import set_state
|
from authentication.tasks import set_state
|
||||||
from eveonline.tasks import refresh_api
|
from eveonline.tasks import refresh_api
|
||||||
|
|
||||||
from eve_sso.decorators import token_required
|
from esi.decorators import token_required
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ def add_api_key(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@token_required(new=True)
|
@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))
|
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)
|
api = get_object_or_404(EveApiKeyPair, api_id=api_id)
|
||||||
if api.user and api.user != request.user:
|
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)
|
logger.debug('API %s has already been verified.' % api_id)
|
||||||
messages.info(request, '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')
|
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))
|
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
|
characters = EveApiManager.get_characters_from_api(api.api_id, api.api_key).result
|
||||||
if token.character_id in characters:
|
if token.character_id in characters:
|
||||||
|
@ -22,4 +22,4 @@ git+https://github.com/celery/django-celery
|
|||||||
git+git://github.com/nikdoof/python-ts3.git
|
git+git://github.com/nikdoof/python-ts3.git
|
||||||
git+https://github.com/pyghassen/openfire-restapi
|
git+https://github.com/pyghassen/openfire-restapi
|
||||||
|
|
||||||
git+https://github.com/adarnof/adarnauth-eve-sso
|
git+https://github.com/adarnof/adarnauth-esi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user