#Stronghold
Get inside your stronghold and make all your Django views default login_required
Stronghold is a very small and easy to use django app that makes all your Django project default to require login for all of your views.
WARNING: still in development, so some of the DEFAULTS and such will be changing without notice.
##Installation
Install via pip.
```sh
pip install django-stronghold
```
Add stronghold to your INSTALLED_APPS in your Django settings file
```python
INSTALLED_APPS = (
#...
'stronghold',
)
```
Then add the stronghold middleware to your MIDDLEWARE_CLASSES in your Django settings file
```python
MIDDLEWARE_CLASSES = (
#...
'stronghold.middleware.LoginRequiredMiddleware',
)
```
##Usage
If you followed the installation instructions now all your views are defaulting to require a login.
To make a view public again you can use the public decorator provided in `stronghold.decorators` like so:
###For function based views
```python
from stronghold.decorators import public
@public
def someview(request):
# do some work
#...
```
###for class based views
```python
from django.utils.decorators import method_decorator
from stronghold.decorators import public
class SomeView(View):
def get(self, request, *args, **kwargs):
# some view logic
#...
@method_decorator(public)
def dispatch(self, *args, **kwargs):
return super(SomeView, self).dispatch(*args, **kwargs)
```
##Configuration (optional)
###STRONGHOLD_DEFAULTS
Use Strongholds defaults in addition to your own settings.
**Default**:
```python
STRONGHOLD_DEFAULTS = True
```
You can add a tuple of url regexes in your settings file with the
`STRONGHOLD_PUBLIC_URLS` setting. Any url that matches against these patterns
will be made public without using the `@public` decorator.
###STRONGHOLD_PUBLIC_URLS
**Default**:
```python
STRONGHOLD_PUBLIC_URLS = ()
```
If STRONGHOLD_DEFAULTS is True STRONGHOLD_PUBLIC_URLS contains:
```python
(
r'^%s.+$' % settings.STATIC_URL,
r'^%s.+$' % settings.MEDIA_URL,
)
```
When settings.DEBUG = True. This is additive to your settings to support serving
Static files and media files from the development server. It does not replace any
settings you may have in `STRONGHOLD_PUBLIC_URLS`.
> Note: Public URL regexes are matched against `[HttpRequest.path_info](https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path_info)`
###STRONGHOLD_NAMED_URLS
You can add a tuple of url names in your settings file with the
`STRONGHOLD_NAMED_URLS` setting. Names in this setting will be reversed using
`django.core.urlresolvers.reverse` and any url matching the output of the reverse
call will be made public without using the `@public` decorator:
**Default**:
```python
STRONGHOLD_NAMED_URLS = ()
```
If STRONGHOLD_DEFAULTS is True additionally we search for `django.contrib.auth`
if it exists, we add the login and logout view names to `STRONGHOLD_NAMED_URLS`
##Compatiblity
Test with:
* Django 1.4.x
* Django 1.5
##Contribute
See CONTRIBUTING.md
Metadata
Release files for django-stronghold 0.1.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-stronghold-0.1.1.tar.gz | 4.3 kB | Without provenance | Details for django-stronghold-0.1.1.tar.gz |
Release files / django-stronghold-0.1.1.tar.gz
| Download URL | django-stronghold-0.1.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaf2bf100bcdf1042c7816071a5465e77f76e72d48768da1f249d7d49c3999d2
|
|
BLAKE2b-256 checksum How to use checksums |
f66d6cda2f0dffbc95948a10420c1987dde53fd3ddd4eefc6437e1709cd9b1bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-stronghold 0.1.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.