temp url with time limit

602 views
Skip to first unread message

Faizan

unread,
Apr 23, 2010, 5:26:19 AM4/23/10
to Django users
Wondering if there is a good way to generate temporary URLs that
expire in X days. Would like to email out a URL that the recipient can
click to access a part of the site that then is inaccessible via that
URL after some time period.

Thanks,
Faizian

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

daniels

unread,
Apr 23, 2010, 10:07:06 AM4/23/10
to Django users
Take a look at this Lighttpd module:
http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModSecDownload
You could implement something based on what the module above is doing.

Nick Serra

unread,
Apr 23, 2010, 10:36:03 AM4/23/10
to Django users
Just create a model that stores the url and the expiration time. If
the url is hit past the expiration time, delete it, if it's still
within the time limit, display whatever you want to display. Obviously
this is for a small system, since you would be waiting to delete until
the url is hit, but its quick and easy. To expand on it, make a
deletion script that purges all old urls on a set interval, say daily,
on a cron job.

Bill Freeman

unread,
Apr 23, 2010, 11:25:52 AM4/23/10
to django...@googlegroups.com
Another possibility, if you don't care what the url looks like, is to
encode the date
and a md5 (or other, your choice) checksum in the url. The checksum is formed
by putting a 'secret' where the checksum goes (at the end?) and checksuming
that. When you get a request back, first check the date, since, if it
is expired,
there is no need to perform another checksum. If the date is good, do a new
checksum of the incoming url with the checksum replaced by the 'secret'. If the
result is the same as came in with the request, serve the content, If the sums
don't match, the request has been tampered with, treat it as expired.

Bill
Reply all
Reply to author
Forward
0 new messages