Re: django images nginx and authentication

2009-10-15 Thread Graham Dumpleton



On Oct 15, 9:41 pm, ReneMarxis  wrote:
> Hello
>
> i'm faceing the following problem: i have some application for
> creating image galleries (upload/change...).
> Till now the images are served by an nginx webserver (and are
> therefore open to everyone). The django app is running in apache with
> wsgi.
>
> My problem is i need to restrict the image delivery only to persons
> that are authorized to watch the images. Best would be to include
> djangos authentication with nginx.
>
> Is there any way to accomplish this or any other hints?

If you are using nginx as a front end proxy to Django application
running in Apache/mod_wsgi, then have Django return X-Accel-Redirect
header with location of static file as hosted by nginx. Then setup
nginx with private URL namespace mapping to files. The X-Accel-
Redirect will be allowed to access those private files but not direct
requests to nginx.

In other words, Django authenticates user and if allowed to access
file, sends back that header to have nginx serve it up.

Because Django is serving up the files direct, this will actually be
quite efficient.

Graham
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: django images nginx and authentication

2009-10-15 Thread ReneMarxis

Many thanks.

i will try that out. But sounds to be a good solution :)

On 15 Okt., 15:00, tback  wrote:
> Hi Rene,
>
> look at this:http://wiki.nginx.org/NginxHttpSecureDownload. I personally use
> lighttpd and mod_secdownload and googled the above.
>
> It works like this:
> Your django application and your image server(s) share a secret.
> Your application takes the secret, the url and a timestamp to
> generate a new url consisting of the original url, the timestamp and
> a hash value.
>
> The image server than takes his secret, the timestamp and the url
> to calculate the hash. If the timestamp is not older than your
> specified period and the hash matches the submitted hash the user
> is allowed to download the image.
>
> cheers tback
>
> On Oct 15, 12:41 pm, ReneMarxis  wrote:
>
> > Hello
>
> > i'm faceing the following problem: i have some application for
> > creating image galleries (upload/change...).
> > Till now the images are served by an nginx webserver (and are
> > therefore open to everyone). The django app is running in apache with
> > wsgi.
>
> > My problem is i need to restrict the image delivery only to persons
> > that are authorized to watch the images. Best would be to include
> > djangos authentication with nginx.
>
> > Is there any way to accomplish this or any other hints?
>
> > _thanks rene
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: django images nginx and authentication

2009-10-15 Thread tback

Hi Rene,

look at this:
http://wiki.nginx.org/NginxHttpSecureDownload. I personally use
lighttpd and mod_secdownload and googled the above.

It works like this:
Your django application and your image server(s) share a secret.
Your application takes the secret, the url and a timestamp to
generate a new url consisting of the original url, the timestamp and
a hash value.

The image server than takes his secret, the timestamp and the url
to calculate the hash. If the timestamp is not older than your
specified period and the hash matches the submitted hash the user
is allowed to download the image.

cheers tback

On Oct 15, 12:41 pm, ReneMarxis  wrote:
> Hello
>
> i'm faceing the following problem: i have some application for
> creating image galleries (upload/change...).
> Till now the images are served by an nginx webserver (and are
> therefore open to everyone). The django app is running in apache with
> wsgi.
>
> My problem is i need to restrict the image delivery only to persons
> that are authorized to watch the images. Best would be to include
> djangos authentication with nginx.
>
> Is there any way to accomplish this or any other hints?
>
> _thanks rene

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: django images nginx and authentication

2009-10-15 Thread tback

Hi,

it seems that my first post didn't go through. I'm personally
using lighttpd with mod_secdownload. But google just gave
me this this:
http://wiki.nginx.org/NginxHttpSecureDownload
I'm pretty sure it will serve your needs.

cheers, tback

On Oct 15, 12:41 pm, ReneMarxis  wrote:
> Hello
>
> My problem is i need to restrict the image delivery only to persons
> that are authorized to watch the images. Best would be to include
> djangos authentication with nginx.
>
> Is there any way to accomplish this or any other hints?
>
> _thanks rene

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



django images nginx and authentication

2009-10-15 Thread ReneMarxis

Hello

i'm faceing the following problem: i have some application for
creating image galleries (upload/change...).
Till now the images are served by an nginx webserver (and are
therefore open to everyone). The django app is running in apache with
wsgi.

My problem is i need to restrict the image delivery only to persons
that are authorized to watch the images. Best would be to include
djangos authentication with nginx.

Is there any way to accomplish this or any other hints?

_thanks rene
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---