IP based authentication for Django
To install add the middleware to MIDDLEWARE_CLASSES:
'django_ip_authn.authentication.Middleware',
You also need to add the authentication backend to AUTHENTICATION_BACKENDS. This will probably not already exist, in which case you will want the entirety of this:
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_ip_authn.authentication.Authenticate',
)
By default it will not authenticate until you also add in the IP numbers that it should allow:
VALID_IP_NUMBERS = [
'127.0.0.1', '127.0.1.1', # Allow only localhost IP numbers
]
Currently it will automatically allow the user with ID 1, this is the user that you create during the initial database creation in Django.
There is an optional header to determine which request.META header value to use to get the remote IP number. This defaults to REMOTE_ADDR. If you are behind a HTTP router you may need to set this to something like the X-Forwarded-For:
REMOTE_IP_HEADER='HTTP_X_FORWARDED_FOR'
Make sure that your HTTP router always sets this or you will open the possibility for a remote client to get around the IP number check by just setting a header on the request.
Metadata
Release files for django_ip_authn 0.3.0.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 | |
|---|---|---|---|---|
| django_ip_authn-0.3.0.1.tar.gz | 2.4 kB | Without provenance | Details |
Release files / django_ip_authn-0.3.0.1.tar.gz
| Download URL | django_ip_authn-0.3.0.1.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
791567edd38ee6869e9138b4c61c01e5b8e28fa26bfef186d4a58e7cc0cb1cef
|
|
BLAKE2b-256 checksum How to use checksums |
da94167a87a72eb5be08a0ba7b58026caa1f81920a505687db4a2467cb33f89f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django_ip_authn 0.3.0.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.