Commit c947ca09 authored by Lukas Burgey's avatar Lukas Burgey

Restructure the auth module

parent 96656e7e
......@@ -10,7 +10,7 @@ from oic.oic import Client
from oic.oic.message import RegistrationResponse
from oic.utils.authn.client import CLIENT_AUTHN_METHOD
from . import utils
from .. import utils
LOGGER = logging.getLogger(__name__)
......@@ -90,6 +90,7 @@ def default_idp():
class OIDCTokenAuthBackend(object):
AuthException = Exception('Unable to authenticate user')
def get_userinfo(self, oidc_client, access_token=None):
......@@ -113,6 +114,8 @@ class OIDCTokenAuthBackend(object):
return user_info
def authenticate(self, request, token=None, issuer_uri=None):
from ....models.users import User
if token is None:
return None
......@@ -142,14 +145,13 @@ class OIDCTokenAuthBackend(object):
access_token=token,
)
from ...models.users import User
return User.get_user(
userinfo,
oidc_client,
)
def get_user(self, user_id):
from ...models.users import User
from ....models.users import User
query = User.objects.filter(
user_type='oidcuser',
pk=user_id
......
......@@ -2,7 +2,7 @@
# pylint: disable=abstract-method
from rest_framework import serializers
from .models import OIDCConfig
from .. import OIDCConfig
class OIDCConfigSerializer(serializers.ModelSerializer):
......
......@@ -16,7 +16,7 @@ from rest_framework.response import Response
from .. import utils
from ..models import OIDCConfig, default_idp
from ..serializers import AuthInfoSerializer
from ..models.serializers import AuthInfoSerializer
from ....views.webpage import state_view_data
LOGGER = logging.getLogger(__name__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment