feat: В Swagger UI добавлена JWT-авторизация
This commit is contained in:
@@ -13,7 +13,7 @@ class ToDoListSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
class ToDoListViewSet(viewsets.ModelViewSet):
|
class ToDoListViewSet(viewsets.ModelViewSet):
|
||||||
queryset = ToDoList.objects.all()
|
queryset = ToDoList.objects.all()
|
||||||
serializer_class = ToDoListSerializer
|
serializer_class = ToDoListSerializer
|
||||||
#permission_classes = [permissions.IsAuthenticated] TODO раскомментировать и сделать авторизацию
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ SECRET_KEY = "django-insecure-toz+*lt(ejm!l*)92w2ciqoh^1kz#a(abbpcn54-dbw(nxoy&7
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["0.0.0.0"]
|
ALLOWED_HOSTS = []
|
||||||
|
if DEBUG:
|
||||||
|
ALLOWED_HOSTS = ["0.0.0.0"]
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
@@ -43,6 +44,16 @@ INSTALLED_APPS = [
|
|||||||
"drf_yasg",
|
"drf_yasg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SWAGGER_SETTINGS = {
|
||||||
|
'SECURITY_DEFINITIONS': {
|
||||||
|
'Bearer': {
|
||||||
|
'type': 'apiKey',
|
||||||
|
'name': 'Authorization',
|
||||||
|
'in': 'header'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ toml==0.10.2
|
|||||||
urllib3==1.26.4
|
urllib3==1.26.4
|
||||||
djangorestframework-simplejwt==4.6.0
|
djangorestframework-simplejwt==4.6.0
|
||||||
psycopg2-binary>=2.8
|
psycopg2-binary>=2.8
|
||||||
drf-yasg
|
drf-yasg>=1.20.0
|
||||||
|
|||||||
Reference in New Issue
Block a user