tags:

views:

41

answers:

2

Maybe it's a stupid question, but I'm trying to login to my django app using a form that is outside django. My guess is that I could send a POST request to /login, but that would fail because of the csrf token.

Maybe I'm missing some kind of theoretical background, but I would like to know what's the correct way to achieve this.

Background info: The django authentication is working fine IF you use the django login forms. What I'd like to do is to use an external static html form (on an apache outside django), to post to django directly so when I redirect to my django server, I don't have to login.

A: 

CSRF exists to prevent exactly this. Although you no doubt have good intentions, there's no technical difference between this and a hacker trying to steal access to your site via a real CSRF attack.

Daniel Roseman
I don't get how this could be dangerous, I want to redirect the user from my non-django-site to my django-site. I mean, I won't use any functionality from my other site, I just want to make a full redirection, and using the credentials from the "original" site, so I'm not asking for any info on the django side.
Doppelganger
He's saying that you can't just "post" to your form without CSRF checks because if you then can anyone can (including those with nefarious intentions), and you don't want that.
Andrew Sledge
But I'm actually posting login info, so, anyone with said login info could somehow impersonate the user.
Doppelganger
A: 

Sounds like you need a single-signon service like CAS: http://code.google.com/p/django-cas/

(but it's possible overkill)

Andrew Sledge
It looks interesting but, yes, it's overkill. I don't want to centralize anything (which would be maybe a more efficient solution), I just have an html form hosted in another server, and I have the strings for login and password. So, I would like to take advantage of having that info and have the user logged in in the django server after being redirected.
Doppelganger