Skip to content

Non-Model REST API Plugin Development? #1817

Answered by bryanculver
alextremblay asked this question in Q&A
Discussion options

You must be logged in to vote

So ModelViewSet eventually inherits from APIView (via ModelViewSet > GenericViewSet > GenericAPIView > APIView) and nowhere in the chain does it do anything fancy with the authentication_classes.

These are set by default via the settings.py:

REST_FRAMEWORK = {
    "ALLOWED_VERSIONS": REST_FRAMEWORK_ALLOWED_VERSIONS,
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "rest_framework.authentication.SessionAuthentication",
        "nautobot.core.api.authentication.TokenAuthentication",
    ),
#...

You should safely be able to remove the authentication_classes and permission_classes from their documented example.

EDIT: See below why permission_classes must be set.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@alextremblay
Comment options

@bryanculver
Comment options

@alextremblay
Comment options

Answer selected by alextremblay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants