djangorestframework-api-key-allowbynames

A djangorestframework-api-key decorator to allow access by key names


Keywords
django, djangorestframework-api-key
License
MIT
Install
pip install djangorestframework-api-key-allowbynames==1.0.1

Documentation

Django RESTframework-api key - Allow by key names

Decorator working with djangorestframework-api-key allowing to restrict access to a method according to the key presented.

Usage

Use @allow_only_apikey() with a list of key names as the first parameter :

from rest_framework_api_key_allowbynames.decorator import allow_only_apikey

class TelegramMemberCheck(APIView):
    permission_classes = [HasAPIKey]

    @allow_only_apikey(['TelegramBot'])
    def get(self, request, format=None):
        pass

If the key does not match, an AuthenticationFailed is returned.