Skip to content

Commit f5d9cfd

Browse files
committed
GH-14: Update the usage for devices
1 parent 82bb3bb commit f5d9cfd

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,57 @@ After connecting the Django Forbid to your project, you can define the set of de
4646
All you need is to set the `DJANGO_FORBID` variable in your project's settings. It should be a dictionary with the
4747
following keys:
4848

49+
- `DEVICES` - list of devices to permit or forbid access to
4950
- `COUNTRIES` - list of countries to permit or forbid access to
5051
- `TERRITORIES` - list of territories to permit or forbid access to
5152
- `OPTIONS` - a dictionary for additional settings
52-
- `ACTION` - whether to `PERMIT` or `FORBID` access to the listed zones (default is `FORBID`)
53-
- `PERIOD` - time in seconds to check for access again, 0 means on each request
54-
- `VPN` - use VPN detection and forbid access to VPN users
55-
- `URL` - set of URLs to redirect to when the user is located in a forbidden country or using a VPN
56-
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden country
57-
- `FORBIDDEN_VPN` - the URL to redirect to when the user is using a VPN
53+
- `ACTION` - whether to `PERMIT` or `FORBID` access to the listed zones (default is `FORBID`)
54+
- `PERIOD` - time in seconds to check for access again, 0 means on each request
55+
- `VPN` - use VPN detection and forbid access to VPN users
56+
- `URL` - set of URLs to redirect to when the user is located in a forbidden country or using a VPN
57+
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden country
58+
- `FORBIDDEN_VPN` - the URL to redirect to when the user is using a VPN
59+
- `FORBIDDEN_KIT` - the URL to redirect to when the user is using a forbidden device
60+
61+
Unlike the `COUNTRIES` and `TERRITORIES`, where the middleware decides whether to permit or forbid access based on the
62+
given `ACTION` value, the `DEVICES` list accepts device types where the names starting with `!` are forbidden. This is
63+
done to make it possible to make them all mix together.
64+
65+
```python
66+
# Forbid access to all devices that have a small screen.
67+
'DEVICES': ['!car', '!player', '!peripheral', '!camera']
68+
69+
# Allow access to all devices having regular or large screens.
70+
'DEVICES': ['desktop', 'smartphone', 'console', 'tablet', 'tv']
71+
```
72+
73+
The available device types are: `smartphone`, `peripheral` - refers to all hardware components that are attached to a
74+
computer, `wearable` - common types of wearable technology include smartwatches and smartglasses, `phablet` - a
75+
smartphone having a larger screen, `console` - PlayStation, Xbox, etc., `display`, `speaker` - Google Assistant, Siri,
76+
Alexa, etc., `desktop`, `tablet`, `camera`, `player` - iPod, Sony Walkman, Creative Zen, etc., `phone`, `car` - refers
77+
to a car browser and `tv` - refers to TVs having internet access.
5878

5979
```python
6080
DJANGO_FORBID = {
81+
'DEVICES': ['desktop', 'smartphone', 'console', 'tablet', 'tv'],
6182
'COUNTRIES': ['US', 'GB'],
6283
'TERRITORIES': ['EU'],
6384
'OPTIONS': {
6485
'ACTION': 'PERMIT',
6586
'PERIOD': 300,
6687
'VPN': True,
6788
'URL': {
68-
'FORBIDDEN_LOC': 'forbidden_country',
89+
'FORBIDDEN_LOC': 'forbidden_location',
6990
'FORBIDDEN_VPN': 'forbidden_network',
91+
'FORBIDDEN_KIT': 'forbidden_device',
7092
},
7193
},
7294
}
7395
```
7496

75-
The available ISO 3166 alpha-2 country codes are listed in [here](https://www.iban.com/country-codes). And the available
76-
ISO continent codes are: `AF` - Africa, `AN` - Antarctica, `AS` - Asia, `EU` - Europe, `NA` - North America, `OC` -
77-
Oceania and `SA` - South America.
97+
The available country codes in the required ISO 3166 alpha-2 format are
98+
listed [here](https://www.iban.com/country-codes). And the available continent codes (territories) are: `AF` -
99+
Africa, `AN` - Antarctica, `AS` - Asia, `EU` - Europe, `NA` - North America, `OC` - Oceania and `SA` - South America.
78100

79101
_None of the settings are required. If you don't specify any settings, the middleware will not do anything._
80102

0 commit comments

Comments
 (0)