{"id":16417367,"url":"https://github.com/pysnippet/django-forbid","last_synced_at":"2026-01-16T11:06:26.243Z","repository":{"id":149451202,"uuid":"620211890","full_name":"pysnippet/django-forbid","owner":"pysnippet","description":"Secure your Django app by controlling the access - grant or deny user access based on device and location, including VPN detection.","archived":false,"fork":false,"pushed_at":"2025-07-26T10:38:52.000Z","size":34227,"stargazers_count":68,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-05T08:53:50.217Z","etag":null,"topics":["access","control","country","detection","device","django","django-forbid","forbid","location","permit","python","secure","security","territory","vpn"],"latest_commit_sha":null,"homepage":"https://docs.pysnippet.org/django-forbid","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pysnippet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-28T08:41:40.000Z","updated_at":"2025-07-26T10:36:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"36aa2816-6b71-4402-9202-225d6ff321d2","html_url":"https://github.com/pysnippet/django-forbid","commit_stats":{"total_commits":142,"total_committers":2,"mean_commits":71.0,"dds":"0.021126760563380254","last_synced_commit":"9bbc8f60074ff26134a04e9b092dbe06fc0da013"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/pysnippet/django-forbid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysnippet%2Fdjango-forbid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysnippet%2Fdjango-forbid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysnippet%2Fdjango-forbid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysnippet%2Fdjango-forbid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pysnippet","download_url":"https://codeload.github.com/pysnippet/django-forbid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysnippet%2Fdjango-forbid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access","control","country","detection","device","django","django-forbid","forbid","location","permit","python","secure","security","territory","vpn"],"created_at":"2024-10-11T07:11:28.327Z","updated_at":"2026-01-16T11:06:26.238Z","avatar_url":"https://github.com/pysnippet.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Django Forbid \u003cimg src=\"https://github.com/pysnippet.png\" align=\"right\" height=\"64\" /\u003e\n\n[![PyPI](https://img.shields.io/pypi/v/django-forbid.svg)](https://pypi.org/project/django-forbid/)\n[![Python](https://img.shields.io/pypi/pyversions/django-forbid.svg?logoColor=white)](https://pypi.org/project/django-forbid/)\n[![Django](https://img.shields.io/pypi/djversions/django-forbid.svg?color=0C4B33\u0026label=django)](https://pypi.org/project/django-forbid/)\n[![Tests](https://github.com/pysnippet/django-forbid/actions/workflows/tests.yml/badge.svg)](https://github.com/pysnippet/django-forbid/actions/workflows/tests.yml)\n[![Docs](https://github.com/pysnippet/django-forbid/actions/workflows/docs.yml/badge.svg)](https://github.com/pysnippet/django-forbid/actions/workflows/docs.yml)\n\nDjango Forbid aims to make website access managed and secure for the maintainers. It provides a middleware to grant or\ndeny user access based on device and/or location. It also supports VPN detection for banning users who want to lie about\ntheir country and geolocation. Also, users can use only the VPN detection feature or disable it.\n\n## Installation\n\n```shell\npython -m pip install django-forbid\n```\n\n## Configuration\n\nAdd the `django_forbid.apps.ForbidConfig` to your `INSTALLED_APPS` in your Django project's **settings.py** file.\n\n```python\nINSTALLED_APPS = [\n    ...,  # other apps\n    'django_forbid.apps.ForbidConfig',\n]\n```\n\nAlso, add the `django_forbid.middleware.ForbidMiddleware` to the `MIDDLEWARE` list of the project.\n\n```python\nMIDDLEWARE = [\n    ...,  # other middlewares\n    'django_forbid.middleware.ForbidMiddleware',\n]\n```\n\nConfiguring the `GEOIP_PATH` variable in your project's settings is important. This variable should contain the path to\nthe GeoLite2 database file. You should [download](https://dev.maxmind.com/geoip/geoip2/geolite2/) the database and\nfollow the Django [documentation](https://docs.djangoproject.com/en/2.1/ref/contrib/gis/geoip2/#settings) for proper\nconfiguration.\n\n## Usage\n\nAfter connecting the Django Forbid to your project, you can define the set of desired zones to be forbidden or allowed.\nAll you need is to set the `DJANGO_FORBID` variable in your project's settings. It should be a dictionary with the\nfollowing keys:\n\n- `DEVICES` - list of devices to permit or forbid access to\n- `COUNTRIES` - list of countries to permit or forbid access to\n- `TERRITORIES` - list of territories to permit or forbid access to\n- `OPTIONS` - a dictionary for additional settings\n    - `VPN` - use VPN detection and forbid access to VPN users\n    - `URL` - set of URLs to redirect to when the user is located in a forbidden country or using a VPN\n        - `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden geolocation\n        - `FORBIDDEN_NET` - the URL to redirect to when the user is using a forbidden network (VPN)\n        - `FORBIDDEN_DEV` - the URL to redirect to when the user is using a forbidden device\n\nThe available device types are: `smartphone`, `peripheral` - refers to all hardware components that are attached to a\ncomputer, `wearable` - common types of wearable technology include smartwatches and smartglasses, `phablet` - a\nsmartphone having a larger screen, `console` - PlayStation, Xbox, etc., `display`, `speaker` - Google Assistant, Siri,\nAlexa, etc., `desktop`, `tablet`, `camera`, `player` - iPod, Sony Walkman, Creative Zen, etc., `phone`, `car` - refers\nto a car browser and `tv` - refers to TVs having internet access.\n\n```python\nDJANGO_FORBID = {\n    'DEVICES': ['desktop', 'smartphone', 'console', 'tablet', 'tv'],\n    'COUNTRIES': ['US', 'GB'],\n    'TERRITORIES': ['EU'],\n    'OPTIONS': {\n        'VPN': True,\n        'URL': {\n            'FORBIDDEN_LOC': 'forbidden_location',\n            'FORBIDDEN_NET': 'forbidden_network',\n            'FORBIDDEN_DEV': 'forbidden_device',\n        },\n    },\n}\n```\n\nThe available country codes in the required ISO 3166 alpha-2 format are\nlisted [here](https://www.iban.com/country-codes). And the available continent codes (territories) are: `AF` -\nAfrica, `AN` - Antarctica, `AS` - Asia, `EU` - Europe, `NA` - North America, `OC` - Oceania and `SA` - South America.\n\n_None of the settings are required. If you don't specify any settings, the middleware will not do anything._\n\n## Contribute\n\nAny contribution is welcome. If you have any ideas or suggestions, feel free to open an issue or a pull request. And\ndon't forget to add tests for your changes.\n\n## License\n\nCopyright (C) 2023 Artyom Vancyan. [MIT](https://github.com/pysnippet/django-forbid/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpysnippet%2Fdjango-forbid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpysnippet%2Fdjango-forbid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpysnippet%2Fdjango-forbid/lists"}