WebFaction
Community site: login faq

In my Django app I'm serving images using the static-only app. Is there any way I can limit access to certain files in this folder when they're requested by the browser?

asked 25 Jan '12, 14:41

aa56280
131614
accept rate: 0%


Static files in webfaction are usually handled by a static app http://docs.webfaction.com/software/static.html and not by django. (you can have a .htaccess file to handle authorizaion) If you want to have django make some tests on the request, I suggest doing something like

def special_permissions_view(request,path):
  if not has_permission(request,path):
     raise Http404()
  return django.contrib.staticfiles.views.serve(request, path)
permanent link

answered 25 Jan '12, 16:49

bono
161
accept rate: 100%

edited 25 Jan '12, 16:51

Static files might be what I'm looking for. Thanks.

(27 Jan '12, 11:11) aa56280

As explained by 'bono' You can not use the standard 'static only' type app to do this as it requires auth and .htaccess. You would have to enforce the restriction at the apache level with the .htaccess file

If you want that basic-auth to integrate with django auth there is some more steps that would need to happen more detail on on option for this is here.

permanent link

answered 25 Jan '12, 18:46

johns
5.3k312
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×908
×125
×12

question asked: 25 Jan '12, 14:41

question was seen: 2,157 times

last updated: 27 Jan '12, 11:11

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM