views:

35

answers:

1

Hi all,

I am making a bookmarklet where I need people to login first. My question is how do I send login credentials to the django server from a different domain?

I was thinking there were a couple ways, since I can't use send data via request.

  1. Generate the sha1 algo on the client-side...but then how do I know what Django is salting with and how can I make that secure?

  2. Find a way to send some post data to my server from a different domain.

Any other ideas/implementations?

Much appreciated

+1  A: 

You can send the POST data (via SSL of course) to your Django site. Your view will handle the request. If you post to that view, you can authenticate using django.contrib.auth methods. The following was taken from http://docs.djangoproject.com/en/dev/topics/auth/

if request.method == 'POST':
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            login(request, user)
            # Send success message.
        else:
            # Return a 'disabled account' error message
    else:
        # Return an 'invalid login' error message.
Andrew Sledge
I will do it through SSL, but does SSL make it crucial? Will it not work with SSL? In my test environment I am not using SSL at the moment (django dev server), and the post request isn't received if it's from a different domain.
Yoshi9143
Without SSL your password is sent in the clear. Theoretically, someone could sniff it out of the communications.
S.Lott
This isn't working. The request object comes up empty. Any ideas?
Yoshi9143