From 4783871f84416e4e15e657df7a5fc745aa3e3438 Mon Sep 17 00:00:00 2001 From: puckoprutt Date: Sat, 22 Feb 2025 13:05:41 +0100 Subject: [PATCH] removed session based authentication and forced token based authentication. --- settings/settings.py | 4 ++-- users/base.py | 4 +--- users/views.py | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/settings/settings.py b/settings/settings.py index 49d84c3..b2f811e 100644 --- a/settings/settings.py +++ b/settings/settings.py @@ -99,7 +99,7 @@ REST_FRAMEWORK = { ], "DEFAULT_AUTHENTICATION_CLASSES": [ "knox.auth.TokenAuthentication", - "rest_framework.authentication.SessionAuthentication" + #"rest_framework.authentication.SessionAuthentication" ], "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", 'DEFAULT_PAGINATION_CLASS': 'settings.puckignation.MediumPagination', @@ -135,7 +135,7 @@ REST_KNOX = { "AUTO_REFRESH": False, "AUTO_REFRESH_MAX_TTL": None, "MIN_REFRESH_INTERVAL": 60, - "AUTH_HEADER_PREFIX": "Bearer", + "AUTH_HEADER_PREFIX": "PuckoToken", "EXPIRY_DATETIME_FORMAT": api_settings.DATETIME_FORMAT, "TOKEN_MODEL": "knox.AuthToken" } diff --git a/users/base.py b/users/base.py index 74a1e81..ea959f5 100644 --- a/users/base.py +++ b/users/base.py @@ -94,16 +94,14 @@ class PuckoBase_User(AbstractBaseUser, PermissionsMixin): return cls.objects.get(username=username) @classmethod - def create(cls, username, password, first_name=None, last_name=None, superuser=False): + def create(cls, username, password, superuser=False): if superuser: cls.objects.create_superuser( username, password=password, - first_name=first_name, last_name=last_name ) else: cls.objects.create_user( username, password=password, - first_name=first_name, last_name=last_name ) return cls.this(username) diff --git a/users/views.py b/users/views.py index b653217..c05d4e5 100644 --- a/users/views.py +++ b/users/views.py @@ -2,7 +2,6 @@ from django.contrib.auth import get_user_model from django.contrib.auth import login from rest_framework.authtoken.serializers import AuthTokenSerializer -from rest_framework.authentication import BasicAuthentication from rest_framework.permissions import AllowAny from rest_framework.permissions import IsAuthenticated from rest_framework.generics import CreateAPIView