repoze.what.plugins.ip
It is a repoze.what plugin that provides an ip_from predicate.
Installation
$ <env>/bin/easy_install repoze.what.plugins.ip
pip:
$ <env>/bin/pip install repoze.what.plugins.ip
Source
The source code can be found at code.google.com.
Usage
ip_from([allowed=None], [proxies=None]) checks whether REMOTE_ADDR in the environment points to an allowed IP address. If HTTP_X_FORWARDED_FOR is set in the environment (meaning proxy access) then REMOTE_ADDR is treated as a proxy address and HTTP_X_FORWARDED_FOR as an originating IP address.
- allowed optional, default - None
A list of IPs to allow access. Can be a string which is then interpreted as a single IP address
- proxies optional, default - None
If a list or tuple provided then treated as a list of authorized proxy IP addresses.
If a string or unicode provided then treated as a single IP address.
Any other value - bool(proxies) == True means that all proxies are accepted
You can filter the incoming IP address:
>>> from repoze.what.plugins.ip import ip_from
>>> p = ip_from(allowed=['192.168.1.1'])
>>> env = {'REMOTE_ADDR': '192.168.1.1'}
>>> p.is_met(env)
True
>>> env = {'REMOTE_ADDR': '192.168.1.10'}
>>> p.is_met(env)
False
By default proxy access is disabled. You can enable it with proxies=True:
>>> p = ip_from(allowed=['192.168.0.0/24'], proxies=True)
>>> env = {
... 'REMOTE_ADDR': '192.168.1.1', # proxy
... 'HTTP_X_FORWARDED_FOR': '192.168.1.5' # origin
... }
>>> p.is_met(env)
True
And you can also explicitly specify proxies to allow:
>>> p = ip_from(allowed='192.168.1.5', proxies=['192.168.0.0/24'])
>>> env = {
... 'REMOTE_ADDR': '192.168.1.1', # proxy
... 'HTTP_X_FORWARDED_FOR': '192.168.1.5' # origin
... }
>>> p.is_met(env)
True
Metadata
Release files for repoze.what.plugins.ip 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| repoze.what.plugins.ip-0.2.tar.gz | 17.8 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| repoze.what.plugins.ip-0.2-py2.6.egg | Legacy Egg format | - | - | Details |
| repoze.what.plugins.ip-0.2-py2.5.egg | Legacy Egg format | - | - | Details |
Total release size: 91.5 kB
Release files / repoze.what.plugins.ip-0.2.tar.gz
| Download URL | repoze.what.plugins.ip-0.2.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6837ff113c8e07068800a925248053cfbc2c12a93d94b9732b3b1ba5e01a5d5
|
|
BLAKE2b-256 checksum How to use checksums |
c03b15dfbc57cbedf2bf75e8bcfb550f658845e3449078e27b9abe5a2413d497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / repoze.what.plugins.ip-0.2-py2.6.egg
| Download URL | repoze.what.plugins.ip-0.2-py2.6.egg |
|---|---|
| Size | 36.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
366e0a6019db02a35a128917a04e8d691b2f55944d0b0131b51446844b49f049
|
|
BLAKE2b-256 checksum How to use checksums |
b33124a8d64e2338b5b20bb8cb29830408c283218cf683ae7c5d3316ccff1918
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / repoze.what.plugins.ip-0.2-py2.5.egg
| Download URL | repoze.what.plugins.ip-0.2-py2.5.egg |
|---|---|
| Size | 36.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
ba20b4ad7e15a4d554239cfada336cf7663d2a330ccff75fd64f73915b8adc39
|
|
BLAKE2b-256 checksum How to use checksums |
69fa6a1568c343734d8ea6f7095c673986ef582363d8805289279db1c596ef0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |