Foros del Web » Programando para Internet » Python »

Django rest framework Authentication personalizada

Estas en el tema de Django rest framework Authentication personalizada en el foro de Python en Foros del Web. hola tengo un problema estoy creando un sistema de authencation con django rest framework Código: class SuperUserSessionAuthentication(authentication.BaseAuthentication): def authenticate(self, request): username = request.META.get('X_USERNAME') # get ...
  #1 (permalink)  
Antiguo 21/09/2016, 21:03
 
Fecha de Ingreso: diciembre-2011
Mensajes: 408
Antigüedad: 12 años, 3 meses
Puntos: 18
Django rest framework Authentication personalizada

hola tengo un problema estoy creando un sistema de authencation con django rest framework

Código:
class SuperUserSessionAuthentication(authentication.BaseAuthentication):
    def authenticate(self, request):
        username = request.META.get('X_USERNAME') # get the username request header
        password = request.META.get('X_PASSWORD')
        print username
        if not username: # no username passed in request headers
            return None # authentication did not succeed

        try:
            user = User.objects.get(email=username) # get the user
            if user.check_password(password):
                return (user, None)
        except User.DoesNotExist:
            raise exceptions.AuthenticationFailed('No such user') # raise exception if user does not exist 

        return (user, None) # authentication successful
    
    def authenticate_header(self, request):
        
        return 'Basic'
cuando agrego los headers usando postman me dicen que no estan

en mis settings
Código:
REST_FRAMEWORK = { 
    'DEFAULT_AUTHENTICATION_CLASSES': (
       'src.user_site.rest_authentication.SuperUserSessionAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'src.user_site.rest_authentication.IsAuthenticated',
    ),

Última edición por minimal; 21/09/2016 a las 21:18

Etiquetas: django, framework, personalizada, rest
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:21.