Tokenauth
=====================================================================
Tokenauth developed for django rest token authentication. It enables you to define expiration time and token prefix. Tokens generate with random data and it use SHA-256 algorithm.
Installation
============
on Pypi
::
pip install tokenauth
on Github
::
git clone git@github.com:ahmetkotan/tokenauth.git
cd tokenauth
python setup.py install
Settings
============
Added to `INSTALLED_APPS`.
::
INSTALLED_APPS = [
...
'tokenauth',
...
]
Added to `urls.py`.
::
urlpatterns = [
...
url(r'^<your-login-url>/', include('tokenauth.urls')),
...
]
Definition in `settings.py`
::
TOKEN_EXPIRATION_TIME = 60 * 60 * 24 * 3 # Default 3 days
TOKEN_PREFIX = "Bearer"
TOKEN_REFRESH = True
Usage
=====
Definition in `settings.py`
::
# Rest Framework
REST_FRAMEWORK = {
...
'DEFAULT_AUTHENTICATION_CLASSES': (
'tokenauth.auth.TokenAuthentication',
),
...
}
Or in `views.py`
::
from tokenauth.auth import TokenAuthentication
class SimpleView(ModelViewset):
authentication_classes = (TokenAuthentication, )
Created token and login:
::
curl -X POST -H "Content-Type: application/json" -d '{"username": "<username>", "password":"<password>"}' <your-django-url>/<your-login-url>/tokens/
Refresh token:
::
curl -X PUT -H "Content-Type: application/json" -d '{"key": "<your-valid-token>"}' <your-django-url>/<your-login-url>/tokens/
Deleted token and logout:
::
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: <your-token>" <your-django-url>/<your-login-url>/tokens/
Metadata
Release files for tokenauth 0.9.1
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 |
|---|---|---|---|---|
| tokenauth-0.9.1.tar.gz | 4.4 kB | Without provenance | Details for tokenauth-0.9.1.tar.gz |
Release files / tokenauth-0.9.1.tar.gz
| Download URL | tokenauth-0.9.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f732eefa401ccef227e311cdcc6719a9838f276f223fe32ac79e12146b32d49
|
|
BLAKE2b-256 checksum How to use checksums |
c535dd3553917c4b5e06bcf8cbc574111442bacdd098e677c117d5bc38c3fe3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.5
|
Security for tokenauth 0.9.1
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.