add rest framework authentication
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
pierre.geeraert
2026-09-22 10:01:09 +01:00
parent 5908d8d282
commit 3294e70b3f
4 changed files with 19 additions and 2 deletions
+9 -2
View File
@@ -5,6 +5,8 @@ from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse
from apps.import_aggregator.import_rest_framework import api_view, authentication_classes, permission_classes,TokenAuthentication,IsAuthenticated,Response,status
from .utils import import_namespace,retrieve_and_apply
from apps.kubernetes_connection.utils import scale_up,scale_down
from .models import Deployment_Data,Ingress_Data
@@ -35,7 +37,10 @@ def scale_down_gui(request,namespace_name,deploy_name):
return render(request, 'dashboard/shutdown.html',
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
@csrf_exempt
@api_view(['POST'])
@authentication_classes([TokenAuthentication])
@permission_classes([IsAuthenticated])
def add_ingress(request):
url = request.POST.get('url')
namespace = request.POST.get('namespace')
@@ -49,7 +54,9 @@ def add_ingress(request):
return JsonResponse({"status": "added","url":str(url),"namespace":str(namespace)})
@csrf_exempt
@api_view(['POST'])
@authentication_classes([TokenAuthentication])
@permission_classes([IsAuthenticated])
def delete_ingress(request):
url = request.POST.get('url')
namespace = request.POST.get('namespace')
@@ -0,0 +1,6 @@
from rest_framework.decorators import api_view, authentication_classes, permission_classes
from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework import status
+3
View File
@@ -54,6 +54,9 @@ INSTALLED_APPS = [
'import_export',
'djangoql',
'admin_extra_buttons',
'rest_framework',
'rest_framework.authtoken',
]
MIDDLEWARE = [
+1
View File
@@ -17,3 +17,4 @@ xmltodict
whitenoise
djangoql
django-admin-extra-buttons
djangorestframework