aaugustin / django-resto

REplicated STOrage for Django, file backends that mirror media files to several servers over HTTP [UNMAINTAINED]
https://django-resto.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
104 stars 8 forks source link

Allow to use http basic authentication and custom headers #4

Closed max-arnold closed 11 years ago

max-arnold commented 11 years ago

I'm unsure about this one, it was extracted from my private fork and is not used in production. Right now we maintain IP access list with list of servers which are allowed to modify files, but this becomes problematic with more and more servers added.

The patch is not finished - there is no way to specify headers in settings or via DistributedStorage instance. It does not break existing tests, but I haven't tested it after extraction from my fork.

It manually constructs Authorization header in order to avoid double HTTP requests.

What is your opinion on this feature?

aaugustin commented 11 years ago

I'd prefer to refactor the implementation to make it easy to customize the HTTP requests through subclassing.

That seems more future-proof and generally useful than implementing basic auth (and then digest auth, and then proxies, and then... the list is endless).

max-arnold commented 11 years ago

Do you have any ideas of how this could be designed? I can imagine the following:

my_model_transport = CustomTransport(options, ...)
my_model_storage = DistributedStorage(transport=my_model_transport)

class MyModel(models.Model):
    image = ImageField(storage=my_model_storage, ...)

Haven't decided what to do with base_url which is passed from Storage instance to Transport.

aaugustin commented 11 years ago

Do the changes in https://github.com/aaugustin/django-resto/pull/6 address your needs?

max-arnold commented 11 years ago

Yes. Thanks a lot!

aaugustin commented 11 years ago

Cool. I've merged it and I'm going to release 1.1 shortly.