[](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.
Metadata
Release files for django-smart-proxy 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-smart-proxy-0.2.1.tar.gz | 7.7 kB | Without provenance | Details for django-smart-proxy-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django-smart-proxy-0.2.1.macosx-10.9-x86_64.tar.gz | Details for django-smart-proxy-0.2.1.macosx-10.9-x86_64.tar.gz |
Total release size: 23.7 kB
Release files / django-smart-proxy-0.2.1.tar.gz
| Download URL | django-smart-proxy-0.2.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1f9f8b4ab7fc17bf9b0d4e4f68a45dec25bad5c4f0831d2d1ac86e4304e6e48
|
|
BLAKE2b-256 checksum How to use checksums |
615f5f35bea47a00250db084f509da9b86ca9f1c344c8c8d280e3348d94250d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django-smart-proxy-0.2.1.macosx-10.9-x86_64.tar.gz
| Download URL | django-smart-proxy-0.2.1.macosx-10.9-x86_64.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
487ed262825db20c5d767ae665d1a70ebd12b2f62d712f13889850aa7588ca3e
|
|
BLAKE2b-256 checksum How to use checksums |
932baa41e8e2f5fc0c1b81f8404b1789b053af400390885ae2bac0110ee4917d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-smart-proxy 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.