Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/09/2016, 21:03
minimal
 
Fecha de Ingreso: diciembre-2011
Mensajes: 408
Antigüedad: 12 años, 4 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