Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda