Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Apache 403 loading video through HTML5 Video player

I have an Django application that streams videos. The application uses drf_firebase_auth. I have tested streaming videos using Postman, the Python requests library, and through the HTML5 video player (using cookie authentication after a sign-in process).

When the application is run locally, video streaming works when called by Postman, Python requests library, and the HTML5 player. When the application is run on AWS, video streaming works through Postman and the Python requests library, but it fails with a 403 when trying to stream through the HTML5 video player.

During debugging I put print statements in the drf_firebase_auth code. The print statements appear in the apache error log when the video is streamed (i.e. through postman or Python requests), but not when called from the HTML5 player. That seems to indicate that the 403 is happening before getting to Django.

Any debugging guidance is appreciated.

Thanks.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

My problem was a combination of misunderstanding some Django authentication processes, forgetting to clear cookies, and the drf_firebase_auth package not supporting cookie authentication.

To support cookie authentication while using drf_firebase_auth, I extended the package and overrode the get_token function. The get_token function was modified to look for the authorization cookie when the authorization header is not found.

Is that the right way to do this?

import  sys, os

import drf_firebase_auth.authentication

from drf_firebase_auth.settings import api_settings
from drf_firebase_auth.settings import api_settings
from rest_framework import (
    authentication,
    exceptions
)
from django.utils.encoding import smart_text

class FirebaseCookieAuthentication (drf_firebase_auth.authentication.FirebaseAuthentication):

    def get_token(self, request):
        """
        Parse Authorization header and retrieve JWT
        """
        authorization_header = \
            authentication.get_authorization_header(request).split()
        auth_header_prefix = api_settings.FIREBASE_AUTH_HEADER_PREFIX.lower()

        #changed code begins

        if not authorization_header or len (authorization_header) != 2:
            for k, v in request.COOKIES.items():
                if k.lower() == "authorization":
                    authorization_header = v.split (' ', 1)
                    break

        #changed code ends

        if not authorization_header or len(authorization_header) != 2:
            raise exceptions.AuthenticationFailed(
                'Invalid Authorization header format, expecting: JWT <token>.'
            )

        if smart_text(authorization_header[0].lower()) != auth_header_prefix:
            raise exceptions.AuthenticationFailed(
                'Invalid Authorization header prefix, expecting: JWT.'
            )

        return authorization_header[1]

Thanks.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!