문제

An app I have been hired to work on is using django-permission.

Every view in the application requires authentication, but I need to create a simple way so I can have endpoints that doesn't require authentication. One usecase is for /callbacks.

I would like to create a custom decorator that I can use for such views.

Any hints or examples?

What I would prefer is:

@permission_required('none')
def callback_transloadit(request, pres_id):
도움이 되었습니까?

해결책

This is how I solved it:

from django.contrib.auth.decorators import user_passes_test
from django.views.decorators.csrf import csrf_exempt


def allow_all(self):
    return True

@user_passes_test(allow_all)
@csrf_exempt
def callback_transloadit(request, pres_id):
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top