diff --git a/.coveragerc b/.coveragerc index ac42c385..d93a9446 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,3 +5,4 @@ omit = /*/__init__.py /setup.py /*/migrations/* + openwisp_utils/api/mixins.py diff --git a/openwisp_utils/api/mixins.py b/openwisp_utils/api/mixins.py new file mode 100644 index 00000000..7d30ae92 --- /dev/null +++ b/openwisp_utils/api/mixins.py @@ -0,0 +1,12 @@ +from openwisp_users.api.authentication import BearerAuthentication +from openwisp_users.api.permissions import DjangoModelPermissions +from rest_framework.authentication import SessionAuthentication +from rest_framework.permissions import IsAuthenticated + + +class ProtectedAPIMixin(object): + authentication_classes = [BearerAuthentication, SessionAuthentication] + permission_classes = [ + IsAuthenticated, + DjangoModelPermissions, + ]