This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

The django-smart-proxy app allows you to configure plug-and-play reverse proxy solutions for social networks and other complex integration points with your website.

Project Description
[![Latest Version](https://pypip.in/version/django-smart-proxy/badge.svg)](https://pypi.python.org/pypi/django-smart-proxy/)
[![Downloads](https://pypip.in/download/django-smart-proxy/badge.svg)](https://pypi.python.org/pypi/django-smart-proxy/)

Django Smart Proxy
==================
Django Smart Proxy is a plug-and-play solution for implementing pass-through proxies in
a Django-based environment.

**Extensibility**<br/>
Django Smart Proxy exposes a *request_decorators* parameter that makes it easily
extensible, allowing access to the request "pipeline" before being sent to the host.

**Common Use Cases**
- Handling OAuth on the server-side to avoid exposing secret keys to the client.
- As an alternative to CORS for making cross-domain AJAX requests.
- Anything else...?


Installation
============
**Requires**
- Python >= 2.6 (supports up to 3.4)
- Django >= 1.4 (Python 2 support up to 1.6.x)

*For all requirements, see <a href="https://github.com/celerityweb/django-smart-proxy/blob/master/setup.py" target="_blank">setup.py</a>.*

**Installing**
```
pip install django-smart-proxy
```

Usage
=====
1. Add ```smart_proxy``` to ```INSTALLED_APPS``` in your ```settings.py```.

**Example**
```python
INSTALLED_APPS = (
...,
'smart_proxy',
...,
)
```

2. Add a ```SMART_PROXIES``` dictionary to ```settings.py``` to configure an arbitrary number of proxies.

**Example**
```python
SMART_PROXIES = {
'instagram': {
'host_endpoint': 'https://api.instagram.com/v1/',
'allowed_methods': ('get', 'put', 'post', 'delete',),
'timeout': 60.0,
},
'twitter': {
'host_endpoint': 'https://api.twitter.com/1.1/',
'allowed_methods': ('get', 'put', 'post', 'delete',),
'timeout': 60.0,
'request_decorators': (
'channel.apps.twitter_auth.utils.append_authorization_header',
),
},
}
```
3. Edit your ```urls.py``` to configure a root URL mapping for the proxies.

**Example**
```python
urlpatterns = patterns(
...,
url(r'^proxy/', include('smart_proxy.urls')),
...,
)
```
4. If applicable, provide an implementation for your request decorators.

**Example**
```python
from django.conf import settings
from requests_oauthlib import OAuth1

def append_authorization_header(request, session):
"""
This function decorates requests to the Twitter proxy with a
signed oauth-compliant Authorization header.
"""

client_key = getattr(settings, 'SOCIAL_AUTH_TWITTER_KEY', None)
client_secret = getattr(settings, 'SOCIAL_AUTH_TWITTER_SECRET', None)

if client_key and client_secret:
request.auth = OAuth1(
client_key,
client_secret=client_secret,
resource_owner_key=session.get('twitter_oauth_token'),
resource_owner_secret=session.get('twitter_oauth_token_secret'))

return request
```
5. You're Done!

In this example, your proxies will be available at ```/proxy/instagram/``` and ```/proxy/twitter/``` respectively.
Release History

Release History

This version
History Node

0.2.1

History Node

0.2.0

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-smart-proxy-0.2.1.macosx-10.9-x86_64.tar.gz (16.0 kB) Copy SHA256 Checksum SHA256 any Dumb Binary Mar 3, 2015
django-smart-proxy-0.2.1.tar.gz (7.7 kB) Copy SHA256 Checksum SHA256 Source Mar 3, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting