Metadata-Version: 2.4
Name: django-ssh-tunnel-proxy
Version: 1.0.0
Summary: A Django plugin that allows ssh remote tunnels.
Project-URL: Homepage, https://github.com/SD-Software-Design-GmbH/django-ssh-tunnel-proxy
Project-URL: Issues, https://github.com/SD-Software-Design-GmbH/django-ssh-tunnel-proxy/issues
Author-email: Julian Bürklin <jb@software-design.de>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.6
Description-Content-Type: text/markdown

# django-ssh-tunnel-proxy

Opens an ssh tunnel so your local development server can be accessed remotely

## Quick start
1. Install with `pip install django-ssh-tunnel-proxy`
2. Set the settings described below
3. Start a dev-server using `python manage.py runserver`
4. Open a tunnel using `python manage.py zeromigrations opensshtunnelproxy`
5. Visit the URL displayed in your terminal

## Context manager
Create a temporary tunnel using the context manager
```python
from sshtunnelproxy import tunnel

with tunnel() as remote_url:
    pass  # do something
```

## Available settings
```python
USER: str = getattr(settings, "SSH_TUNNEL_USER", "")
"""The SSH user to use for the tunnel. default: `''`"""

PASSWORD: str = getattr(settings, "SSH_TUNNEL_PASSWORD", "")
"""The SSH password to use for the tunnel. default: `''`"""

PORT_RANGE: tuple[int, int] = getattr(settings, "SSH_TUNNEL_PORT_RANGE", (24000, 24999))
"""The range of ports to use for the tunnel. default: `(24000, 24999)`"""

HOST: str = getattr(settings, "SSH_TUNNEL_HOST", "")
"""The host to tunnel to. default: `''`"""

URL_GENERATOR: Callable[[int], str] = getattr(
    settings, "SSH_TUNNEL_URL_GENERATOR", lambda port: f"http://{HOST}:{port + 1}"
)
```

## Remote server
For this to work, you need a remote web server to reverse-proxy the tunneled port.

## What else
Make sure to add `SSH_TUNNEL_HOST` to your `ALLOWED_HOSTS`.  
Also, `SESSION_COOKIE_SECURE = False` must be set, or else you won't be able to log in.