title: Django-Rest-Framework system to check custom HTTP header (application - token)
body: <p>I use Django and Django- rest-framework.
  I have to check a custom http header for a lot of my views.</p>
  
  <p>For each view I need to:</p>
  
  <ul>
  <li>Check if the http custom header is there (X-APP-TOKEN);</li>
  <li>Check if this token is correct;</li>
  <li>Serve the request or return an HTTP error (for example 403);</li>
  </ul>
  
  <p>Is there some approach that I can follow?
  For example something like permissions_class for rest-framework view.
  I tried to implement a custom permission like this:</p>
  
  <pre><code>class IsAuthorizedApplication(BasePermission):
  
  def has_permission(self, request, view):
  
      app_id = request.META.get(app_settings.APPS_HEADER_AUTHORIZATION_APP_ID)
      secret_token = request.META.get(app_settings.APPS_HEADER_AUTHORIZATION_APP_TOKEN)
  
      if app_id and secret_token:
  
          try:
              selected_app = Application.objects.get(app_uuid=app_id, status=ApplicationStatusType.ACTIVE)
              // Check secret token
              return True
          except Application.DoesNotExist:
              return False
      return False
  </code></pre>
  
  <p>But I think that this approach is based to the authentication system of <code>djnago-rest-framework</code>. Infact in case of 'false return' I receive:</p>
  
  <pre><code>401 - {"detail":"Authentication credentials were not provided."}
  </code></pre>
  
  <p>Is there some different approach to check custom http headers like the permission-class or have I to write a base View to check the application-token before to serve the request?</p>