2010/3/26 Simone Orsi <simah...@gmail.com> > Hi *, > > I'm trying to set some webservices using rpc4django (cause it supports > also jSON) on Django 1.1. > > I followed this > > http://packages.python.org/rpc4django/#overview > > and this > > http://docs.djangoproject.com/en/1.1/howto/auth-remote-user/ > > so that in my settings.py I have > > MIDDLEWARE_CLASSES = ( > # 'django.middleware.cache.UpdateCacheMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.contrib.auth.middleware.RemoteUserMiddleware', > [...] > ) > > and > > AUTHENTICATION_BACKENDS = ( > 'lfs.customer.auth.EmailBackend', > # 'django.contrib.auth.backends.ModelBackend', > 'django.contrib.auth.backends.RemoteUserBackend', > ) > > Here's the string I use to connect: > > s = ServerProxy('http://admin:ad...@localhost:8000') > > With public methods everything works fine (evan without "admin:admin@") > but with protected methods I get a "404 Forbidden". > > Debugging trough the request shows me that the user is still anon: > > (Pdb) kwargs.get('request').user > <django.contrib.auth.models.AnonymousUser object at 0xa9960cc> > > So, it seems to me that the normal http auth doesn't work. > > Is this supposed to work and am I missing something or should I handle > login/logout actions within an ad-hoc webservice? > >
Hi, I'm also using rpc4django, I remember I did something like this: class HttpAuthMiddleware: """ Simple HTTP-Basic auth for testing webservices """ def process_request(self, request): auth_basic = request.META.get('HTTP_AUTHORIZATION') if auth_basic: import base64 try: username , dummy, password = base64.decodestring(auth_basic[6:]).partition(':') user = User.objects.get(username=username) if user.check_password(password): request.user = user except User.DoesNotExist: return None Now I can call ws with curl -v -d @test.xml "http://username:passw...@localhost:8000/RPC2" -- Alessandro Pasotti w3: www.itopen.it -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.