Sunday, May 8, 2011

curl pages behind login_required

I am trying to curl pages that require being logged in via django's
default auth. I don't care if the actual login is done with curl,
python, firefox or whatever is easiest.

This only works sometimes, so I am missing something:

install https://addons.mozilla.org/en-us/firefox/addon/export-cookies/
./manage.py runserver
browse FF to http://localhost:8080/admin/
log in
FF tools/export cookies/cookeis.txt
$ grep localhost cookies.txt
localhost FALSE / FALSE 1306094671 sessionid
754305fdac240f1ab68371b1f860eaa0
localhost FALSE / FALSE 1336334661 csrftoken
4fa9c0c4f6cb537df8389fb63df61f3b

$ curl -s --cookie sessionid=754305fdac240f1ab68371b1f860eaa0
http://localhost:8080/admin/ | grep "Log out"
Log out</a>

good - you only get "Log out" if you are logged in. So that works.

When I try it with the production site (log in, save cookes, grep
hostname use that session id...), I get the login form html, meaning
it isn't seeing me as logged in.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate