Add “drf_secure_token” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'rest_framework', 'drf_secure_token', ]Add following lines to your settings.py:
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.BasicAuthentication', 'drf_secure_token.authentication.SecureTokenAuthentication', ] }For updating token add this middleware to your MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = ( ... 'drf_secure_token.middleware.UpdateTokenMiddleware', )Add UPDATE_TOKEN to your ‘dev’ settings if you don’t want to update token in DEBUG mode:
UPDATE_TOKEN = False
Add TOKEN_AGE to your settings:
TOKEN_AGE = 60*10 # 10 min
(Optional) To cleanup dead tokens celery can be used. Way to enable depends from celery version
6.1 Celery 4, just enable it with settings:
REMOVE_TOKENS_THROUGH_CELERY = True
6.2 Celery 5, add periodic task manually:
@app.on_after_finalize.connect
def setup_periodic_tasks(sender, **kwargs):
from drf_secure_token.tasks import DELETE_OLD_TOKENS
app.conf.beat_schedule.update({
'drf_secure_token.tasks.delete_old_tokens': DELETE_OLD_TOKENS,
})
Run python manage.py migrate to create the drf_secure_token models.
Metadata
Release files for drf-secure-token 1.2.0
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 | Actions |
|---|---|---|---|---|
| drf-secure-token-1.2.0.tar.gz | 6.4 kB | Without provenance | Details for drf-secure-token-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_secure_token-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for drf_secure_token-1.2.0-py3-none-any.whl |
Total release size: 17.3 kB
Release files / drf-secure-token-1.2.0.tar.gz
| Download URL | drf-secure-token-1.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ebe68cbc8022a27d135ebfc46e59fe3616727e778a07cbd3a3a6c9349b6aff3d
|
|
BLAKE2b-256 checksum How to use checksums |
be3e1a24deac335e5896fb8de91f17b1b9acb6530ab0916b5dbd2edb78f44576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Release files / drf_secure_token-1.2.0-py3-none-any.whl
| Download URL | drf_secure_token-1.2.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38bdc2709b0e1419a05a7807cf56e57923d1131a56ca3241ed6f6866316c0f41
|
|
BLAKE2b-256 checksum How to use checksums |
12186cbc424e00c08865e712d2d89206ede56a1adbceecb90e9f37b54668f956
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for drf-secure-token 1.2.0
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.