Hi,

I'm writing an own auth backend at the moment, but I need access to the
request object.
I found a possible solution with adding settings.request = request into a
middleware, but that's seems not beautilful to me.

My backend is something like this at the moment, to check the hash I need
the clientname (REMOTE_HOST doesn't work):

class MyRemoteUserBackend:

    def authenticate(self, sKey, user):

        username = user
        user = None

        if self.create_unknown_user and check_hash(username, sKey):
            user, created = User.objects.get_or_create(username=username)
            if created:
                user = self.configure_user(user)

        return user

    def clean_username(self, username):
        return username

    def configure_user(self, user):
        user.is_staff = False
        # fetch userinfo from server ...
        user.save()
        return user

    def check_hash(self, username, sKey):
        from time import time
        import socket

        clientname = socket.gethostbyaddr( request.META['REMOTE_ADDR'] )[0]

        if clientname == '':
            clientname = 'nil'

        # check hash and return boolean

Somebody has a nice solution for this?

thx,
Florian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to