diff --git a/djangoldp_account/admin.py b/djangoldp_account/admin.py index 3a67e51fbb44cfac418a1660239f42e222b85485..4f8938c3f8b9e6ec5fb1509226a7573154634974 100644 --- a/djangoldp_account/admin.py +++ b/djangoldp_account/admin.py @@ -6,6 +6,7 @@ from djangoldp_account.models import LDPUser from .models import Account, ChatProfile +@admin.register(Account, ChatProfile) class EmptyAdmin(admin.ModelAdmin): def get_model_perms(self, request): return {} @@ -28,6 +29,7 @@ class ChatProfileInline(admin.StackedInline): extra = 0 +@admin.register(LDPUser) class LDPUserAdmin(DjangoLDPUserAdmin): exclude = ('is_backlink', 'allow_create_backlink') form = LDPUserChangeForm @@ -45,6 +47,3 @@ class LDPUserAdmin(DjangoLDPUserAdmin): ) -admin.site.register(LDPUser, LDPUserAdmin) -admin.site.register(Account, EmptyAdmin) -admin.site.register(ChatProfile, EmptyAdmin) \ No newline at end of file diff --git a/djangoldp_account/auth/backends.py b/djangoldp_account/auth/backends.py index 27230b56de39ec4797ac3992210ff8276d5eb7f8..1188b6a028fc5e985e4a311db3fa5f9ba8dd878e 100644 --- a/djangoldp_account/auth/backends.py +++ b/djangoldp_account/auth/backends.py @@ -157,8 +157,8 @@ class ExternalUserBackend(ModelBackend): return self._get_or_create_then_authenticate({}, jwt['webid']) def authenticate(self, request, username=None, password=None, **kwargs): - if 'HTTP_AUTHORIZATION' in request.META: - jwt = request.META['HTTP_AUTHORIZATION'] + if 'authorization' in request.headers: + jwt = request.headers['authorization'] if jwt.lower().startswith("dpop"): jwt = jwt[5:] return self.validate_dpop_token(request, jwt) diff --git a/djangoldp_account/djangoldp_urls.py b/djangoldp_account/djangoldp_urls.py index 93633ad6e7bec81c29e34d4c26d894a760f18aa6..b601d04a61f1cc85ed956fc9f55888a3855a9568 100644 --- a/djangoldp_account/djangoldp_urls.py +++ b/djangoldp_account/djangoldp_urls.py @@ -34,16 +34,16 @@ urlpatterns = [ name='django_registration_register', ), path('auth/login/', LDPAccountLoginView.as_view(),name='login'), - re_path(r'^auth/', include('django_registration.backends.activation.urls')), - re_path(r'^auth/', include('django.contrib.auth.urls')), - re_path(r'^accounts/', LDPViewSet.urls(model=Account, permission_classes=[LDPPermissions], model_prefix='pk_lookup', + path('auth/', include('django_registration.backends.activation.urls')), + path('auth/', include('django.contrib.auth.urls')), + path('accounts/', LDPViewSet.urls(model=Account, permission_classes=[LDPPermissions], model_prefix='pk_lookup', lookup_field='pk')), - re_path(r'^chat-profile/', LDPViewSet.urls(model=ChatProfile, permission_classes=[LDPPermissions], + path('chat-profile/', LDPViewSet.urls(model=ChatProfile, permission_classes=[LDPPermissions], model_prefix='pk_lookup', lookup_field='pk')), re_path(r'^oidc/login/callback/?$', RPLoginCallBackView.as_view(), name='oidc_login_callback'), re_path(r'^oidc/login/?$', RPLoginView.as_view(), name='oidc_login'), re_path(r'^userinfo/?$', csrf_exempt(userinfocustom)), re_path(r'^check-user/?$', csrf_exempt(check_user)), - re_path(r'^redirect-default/$', RedirectView.as_view(),name='redirect-default'), - re_path(r'^', include('oidc_provider.urls', namespace='oidc_provider')) + path('redirect-default/', RedirectView.as_view(),name='redirect-default'), + path('', include('oidc_provider.urls', namespace='oidc_provider')) ] diff --git a/djangoldp_account/permissions.py b/djangoldp_account/permissions.py index 28dfad1acf0a26220fdfde2eb69ed03e5a37e463..7692ee38f69a0895b5f1ce03c4856e4061a9fea6 100644 --- a/djangoldp_account/permissions.py +++ b/djangoldp_account/permissions.py @@ -10,7 +10,7 @@ if hasattr(settings, 'XMPP_SERVER_IP'): XMPP_SERVERS = XMPP_SERVERS.union(getattr(settings, 'XMPP_SERVER_IP')) def check_client_ip(request): - x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') + x_forwarded_for = request.headers.get('x-forwarded-for') if x_forwarded_for: ip = x_forwarded_for.replace(' ', '').split(',') else: diff --git a/djangoldp_account/views.py b/djangoldp_account/views.py index 82039b459f7b431e547d7726e77d2c7f74cdddbd..df7306be9fa9ef5478868005adb043057e0b1582 100644 --- a/djangoldp_account/views.py +++ b/djangoldp_account/views.py @@ -37,7 +37,7 @@ def check_user(request, *args, **kwargs): '''Returns user if they are authenticated with this server, else 404''' response = HttpResponse({}, status=200) if request.method in ['GET', 'HEAD', 'OPTIONS']: - response['Access-Control-Allow-Origin'] = request.META.get('HTTP_ORIGIN') + response['Access-Control-Allow-Origin'] = request.headers.get('origin') response["Access-Control-Allow-Headers"] = \ oidc_settings.get('OIDC_ACCESS_CONTROL_ALLOW_HEADERS') response["Access-Control-Allow-Credentials"] = 'true' @@ -54,7 +54,7 @@ def check_user(request, *args, **kwargs): response_body['dpop'] = request.headers['Dpop'] response = JsonResponse(settings.userinfo(response_body, request.user)) - response['Access-Control-Allow-Origin'] = request.META.get('HTTP_ORIGIN') + response['Access-Control-Allow-Origin'] = request.headers.get('origin') response["Access-Control-Allow-Headers"] = \ oidc_settings.get('OIDC_ACCESS_CONTROL_ALLOW_HEADERS') response["Access-Control-Expose-Headers"] = "Location, User"