Django-API-Permission
1. Intro
A Django api permission manager that helps you custom api url in regular expression and control access.
2. Quick Start
2.1 Install
pip install django-api-permission
2.2 add to INSTALLED_APPS and MIDDLEWARE
INSTALLED_APPS = [
...
'api_permission',
...
]
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'api_permission.middleware.APIPermCheckMiddleware',
]
2.3 migrate
./manage.py migrate api_permission
2.4 settings
set API_PERMISSION_CONF in your settings.py as a dict.
API_PERMISSION_CONF = {
'API_PREFIX': ['api/topic/'], # default is /
'PERMISSION_DENIED_CODE': 1, # default is 1
'AUTHORIZATION_HEADER': 'HTTP_AUTHORIZATION', # default is HTTP_AUTHORIZATION
'ADMIN_SITE_PATH': '/admin/', # default is /admin/
'TOKEN_EXPIRE': 15, # unit is days, default is None, which won't check token expire.
}
You can custom API_PREFIX as a str like '/' or list like ['api/account', 'api/topic'].
** When you set TOKEN_EXPIRE, you need add below in your REST_FRAMEWORK settings. **
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
...
'api_permission.authentication.ExpireTokenAuthentication',
),
}
3. Demo
3.1 list
3.2 edit
3.3 result
Metadata
Release files for django-api-permission 0.1.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 | Provenance | |
|---|---|---|---|---|
| django-api-permission-0.1.2.tar.gz | 5.2 kB | Without provenance | Details |
Release files / django-api-permission-0.1.2.tar.gz
| Download URL | django-api-permission-0.1.2.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
baa817ca916ec489d7f6ddab2459616ddeb0a534f38bd0533ed5cb6ddc48b2b4
|
|
BLAKE2b-256 checksum How to use checksums |
fe8e15b604224326d08d5d148d3b6c4c798061d4c85fa7663fe30bf4a15e88c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
|
Security for django-api-permission 0.1.2
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.